Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - wait and notifyAll

Tags:

java

wait

What happens when you call notifyAll method on an object that is not waiting? Should there be exception or is it normal situation?

like image 970
mgamer Avatar asked May 06 '09 06:05

mgamer


2 Answers

As you can see here, calling notifyAll() on an not waiting object does not have any effect.

alt text

like image 127
Mork0075 Avatar answered Oct 18 '22 12:10

Mork0075


It is completely normal. You can only notify all that waiting on one single monitor. Everybody else is not interested. The object on which you call notifyAll is just the monitor on which others are waiting. If nobody is waiting nobody has to be notified

like image 41
Norbert Hartl Avatar answered Oct 18 '22 10:10

Norbert Hartl