The difference between sleep, yield, wait a

sleep and yield will not release the lock

sleep cpu not transfer the right to use, only to suspend execution

yield cpu to sell the right to use, but is runnable

wait, notify, notifyall need to hold the lock before being called after the call to release the lock, is a "waiting notification mechanism."

 

notify cpu is free to wake up a thread on an object is locked, it is best to use notifyall

 

Guess you like

Origin www.cnblogs.com/hzq3554055/p/12045829.html