Some methods commonly used thread

sleep () method of the Thread belongs, does not release the lock, automatic wake-up interrupt or break

wait () method of the Object belongs, release the lock will not be automatically wake awake notify () or notifyall ()

notify () / notifyall () a wake up any / all waiting threads on this subject

Wakes up a single thread that is waiting on this object's
monitor. If any threads are waiting on this object, one of them
is chosen to be awakened. The choice is arbitrary and occurs at
the discretion of the implementation. A thread waits on an object's
monitor by calling one of the {@code wait} methods.

Note: wait () and notify () \ nofityall () is combined with the use of, and is in a multithreaded state.

join() https://www.cnblogs.com/DDiamondd/p/11290833.html

yield() : https://www.cnblogs.com/DDiamondd/p/11290942.html

 

Guess you like

Origin www.cnblogs.com/DDiamondd/p/11290981.html