public class AccountSync implements Runnable{static Integer count = 0;static String str ="111";@Overridepublic void run() {for(int j=0;j<10000000;j++){synchronized(count){count++;}}}// static AccountSync account = new AccountSync();public static void main(String[] args) throws InterruptedException {AccountSync account = new AccountSync();Thread t1 = new Thread(account);Thread t2 = new Thread(account);t1.start();t2.start();t1.join();t2.join();System.out.println(count);}}
添加回答
举报
0/150
提交
取消