Here's an interesting behaviour. A thread that has been blocked in
Object.wait is interrupted. But instead of throwing an
InterruptedException, Object.wait returns normally with the thread's
interrupt status set.

This behaviour is not mentioned in javadoc, yet I witnessed it.
Granted, I could only trigger it in an edge case described in JLS. I
wonder if the behaviour is reserved for that edge case, or it can be
observed elsewhere and there is a genuine gap in javadoc. FWIW,
javadoc for j.u.c.Condition documents this behaviour.

Here's a practical implication of this. If some code that uses
Object.wait wants to be interruptible, it must not rely on Object.wait
to throw InterruptedException. It should check interrupt status or
call other methods that are guaranteed to throw InterruptedException
on thread interruption.

-Pavel

Reply via email to