class Test1 implements Runnable {
//Object obj = new Object();
private int piao = 100;
public void run() {
while(true) {
synchronized(obj) { //锁(obj)对象为什么不可以用new Object();呢
if(piao > 0) {
try {Thread.sleep(10);} catch(InterruptedException e) {}
System.out.println("show run..." + piao--);
}
}
}
}
}
|
|