package org.activiti.designer.test;
public class testSyncronize implements Runnable{
public String synMethod(int a1){
synchronized(testSyncronize.class) {
System.out.println("====="+a1);
}
return "返回成功了";
}
public static void main(String[] args) {
testSyncronize syncThread = new testSyncronize();
Thread thread1 = new Thread(syncThread, "SyncThread1");
Thread thread2 = new Thread(syncThread, "SyncThread2");
thread1.start();
thread2.start();
}
public void run() {
// TODO Auto-generated method stub
for(int i=0;i<9;i++){
synMethod(i);
}
}
}
public class testSyncronize implements Runnable{
public String synMethod(int a1){
synchronized(testSyncronize.class) {
System.out.println("====="+a1);
}
return "返回成功了";
}
public static void main(String[] args) {
testSyncronize syncThread = new testSyncronize();
Thread thread1 = new Thread(syncThread, "SyncThread1");
Thread thread2 = new Thread(syncThread, "SyncThread2");
thread1.start();
thread2.start();
}
public void run() {
// TODO Auto-generated method stub
for(int i=0;i<9;i++){
synMethod(i);
}
}
}