RE: JavaMemoryModel: Proposals on wait and interrupts

From: Sylvia Else (
Date: Wed May 28 2003 - 00:13:42 EDT

At 08:45 PM 27/05/2003 -0700, Jerry Schwarz wrote:
>Yes, but this whole discussion got started under the premise that the
>program did issue notifies "around this time". The notify could have been
>done before the interrupter locks the monitor.

Maybe we are talking at slightly cross purposes. The particular algorithm
that David raised in objection to my third proposal was

synchronized void someBlockingMethod() throws InterruptedException
     while (!inRightState)
     // do something

David argued, and I don't disagree, that under the current specification,
interrupting the waiting thread guarantees that the method will throw the
InterruptedException as soon as the thread wakes up, and in particular,
that it will not go round and perform the inRightState test again which
might no longer be capable of evaluation (or perhaps would simply give the
wrong answer).

It is certainly true that if the program issues a notify at around the same
time (and before the interrupt) then the thread is no longer in the wait
state, and that interrupting it will not work. However, since doing this
would break the program, one can reasonably assume that the program is
designed so that it won't.


JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:45 EDT