learning target:
掌握 wait和sleep的区别
For example:
- Master the difference between wait and sleep
Learning Content:
分析sleep和wait的区别
- sleep is a Thread method, and wait is a method of Object
- sleep does not need to be forced to be configured with synchronized, but the wait method must be used with synchronized
- sleep is sleeping,
不会释放锁对象
and wait is waiting会释放锁对象
, and这个线程会进入到Monitor的Waiting中等待被唤醒
when the waiting thread in Waiting is callednotify或者notifyall
,唤醒
it will re-enter the EntryList in the Monitor object.重新竞争