62,628
社区成员
发帖
与我相关
我的任务
分享
public void run() {
int count = 10;
while (count > 0) {
synchronized (a) {
synchronized(b) {
System.out.print(“AAAA”);
count--;
b.notify();
try {
a.wait(); //只会释放对象a的锁,即等待的时候还持有对象b的锁,还是两个锁都释放了?
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}