23,404
社区成员
发帖
与我相关
我的任务
分享
public void run() {
Object obj = new Object();
synchronized (obj) {
while (ticket > 0) {
System.out.println(Thread.currentThread().getName() + "出售: 票" + ticket);
m++;
try {
Thread.currentThread().sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ticket--;
}
}
}