Originally posted by avi aro:
Hi,
Is it possible for a thread to come out of wait state even when the other thread has not called notify. I found the following example in the Sun Certified Programmer and Developer book on thread. This example uses notifyAll(). But even if I comment notify, the program works fine. Any suggestions. how is it possible:
It is an implementation artifact. When the run() method completes, one of the cleanup operations for a thread is to issue a notifyAll() on the thread object. This is needed to wakeup all of the threads that are waiting for the thread to finish -- via the join() method.
In other words, it is working because a notifyAll() *is* being issued.
Henry