| 1. |
What Is The Difference Between Notify() And Notifyall()? |
|
Answer» notify() method 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 random and OCCURS at the discretion of the implementation. NOTIFYALL() wakes up all threads that are waiting on this object’s monitor. A thread WAITS on an object’s monitor by calling one of the WAIT methods. notify() method 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 random and occurs at the discretion of the implementation. notifyAll() wakes up all threads that are waiting on this object’s monitor. A thread waits on an object’s monitor by calling one of the wait methods. |
|