Home > Back-end >  In 2020-09-15: Java wait () and sleep () what are the difference?
In 2020-09-15: Java wait () and sleep () what are the difference?

Time:09-16

In 2020-09-15: Java wait () and sleep () what are the difference? # # f greatly architects a daily topic

CodePudding user response:

Sleep method is thread dormancy, yield the CPU, not releasing the lock
Wait method is thread waiting, releases the lock

CodePudding user response:

Essence is different, the wait is Object, the method of sleep is the method of Thread; Wait don't need to catch exceptions, sleep must catch exceptions; Wait only in a synchronous control method or synchronous control block used inside, sleep can be used in any place,

CodePudding user response:

Sleep is dormant, time available to lock
Wait wait, need to interrupt to acquire the lock

CodePudding user response:

https://blog.csdn.net/weixin_48502062/article/details/108610035

CodePudding user response:

HENHAO

CodePudding user response:

??????????
  • Related