Bill Pugh wrote:
> Proposal 1: a thread performing a wait should prefer throwing an IE over
> returning normally.
With spurius interrupts, it doesn't seem like anything useful can be
formally said about this property. A good implementation should
probably do this, but I don't see how the spec can say anything beyond
that if a thread has been interrupted before entering a wait, then
wait() will throw an InterruptedException.
> Proposal 2: if a thread T1 performing a wait on object m is removed from
> the wait set via a call to m.notify(), and T1 exits the call to wait by
> throwing an IE, then the VM should ensure that another m.notify() is
The alternative is simply to not allow a thread to return with an
InterruptedException if it has been removed from the wait set via a notify.
Overall, from a practical standpoint, I don't think it is important that
in Sylvia's example that thread 2 is woken up and not thread 3.
Waking up thread 3 only will probably not introduce bugs in many
existing Java programs. But I do think that behavior is more
complicated to formally model and is counter-intuitive.
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:45 EDT