Originally posted by Peter Chase:
Say one thread does a notifyAll() on an object, to notify that there have been changes to one particular aspect. All waiting threads will wake up, but only some of them will be interested in the aspect that has changed; the remainder will have experienced a "spurious wake-up".
Well, according to the
java language specifications, this is not what they term as the spurious wakeup. This is infact the required semantics of the notifyAll() method. However, this is one of the reasons why the wait() calls must be inside a conditional loop.
The spurious wakeups are permitted(though not encouraged) for jvm implementations, wherein, they can remove the threads from the object's wait set without any explicit instructions to do so i.e no Interrupt, wait timeout and notify/notifyAll().
[ October 31, 2007: Message edited by: Nitesh Kant ]