Reputation: 67
I am confused on one point with notify method. "notify() : It wakes up one single thread that called wait() on the same object." So lets say two thread called wait for the same object. So when I call notify which thread will be notified?
Upvotes: 0
Views: 25
Reputation: 8617
You can't know which one will be notified. Spec says:
public final void notify()
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.
Upvotes: 1