Is it possible to get java.lang.IllegalMonitorStateException
on notifyAll()
because wait(timeout)
has passed the timeout time?
If not, what happens when notifyAll()
occurs after the timeout time has passed?
Both notifyAll()
and wait(timeout)
are blocked inside a synchronized block on the same locked object.
synchronized(lockObj) {
lockObj.notifyAll();
}
And:
synchronized(lockObj) {
lockObj.wait(timeout);
}
No, you won't get an exception for that. If you call notifyAll
when nothing is waiting, nothing happens basically. It's not an error condition.
See more on this question at Stackoverflow