The javadoc for Object.wait
mentions,
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop.
synchronized (obj) {
while (<condition does not hold>) {
obj.wait(timeout, nanos);
}
... // Perform action appropriate to condition
}
It does not mention that a InterruptedException
needs to be handeled here.
Does that imply that the wait method may spontaniously wakes up without throwing one.
I'd had a look around but didn't find anything specific about how the wakeup is actually processed.
As spurious interrupts are not a thing (or so I have read), I believe that is the case. I am just looking for a confirmation of this.