What is the purpose of the wait (), notify (), and notifyAll() methods?The wait() method makes the thread to halt, thus allowing other thread to perform.
The notify() method triggers back the thread in wait() state to ready state and the execution continues.
The notifyAll() method will trigger all the threads in wait() state to ready state and the execution of all threads continues. These threads will be performed based on the priority and the selection based on JVM.
notify() Wakes up a single thread that is waiting on this object's monitor.
notifyAll() Wakes up all threads that are waiting on this object's monitor.
wait() Causes current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
|