等待()和睡眠()之间的区别
3 回答
BIG阳
TA贡献1859条经验 获得超6个赞
A wait
notify
sleep
wait
notify
synchronized
sleep
Object mon = ...; synchronized (mon) { mon.wait(); }
synchronized (mon) { mon.notify(); }
mon
notifyAll
wait
synchronized
wait
Object
sleep
Thread
.
wait
wait
synchronized { while (!condition) { mon.wait(); } }
Qyouu
TA贡献1786条经验 获得超11个赞
wait()
synchronized(LOCK) { Thread.sleep(1000); // LOCK is held } synchronized(LOCK) { LOCK.wait(); // LOCK is not held }
添加回答
举报
0/150
提交
取消