摘要:
public class MySynchronizedTest implements Runnable {//线程加锁时应是同一对象 int i=100; Object object=new Object(); boolean flag=true; //对方法加锁 public synchronized void count1() { while(flag){ try {//睡眠200ms Thread.sleep(200); } catch (InterruptedException e) { // TODO Auto-generated catch block ... 阅读全文