Sylvia Else wrote:
> The behaviour I would prefer is one where the outcome is as
> if any interrupted threads had never been notified, but had
> simply been interrupted while waiting, with the caveat from
> the specification about the non-predictability where
> interrupt and notify are demonstrably applied to the same
> thread before wait returns. In this case, thread 3 would
> have been notified, and would return normally.
Does it make a difference if the interrupt occurs before or after N
releases the monitor?
Your preferred behaviour makes it appear that the interrupt occurred
before the notification. Yet the time (and intervening actions)
between them could actually be great. If we add a few more threads to
the scenario and interrupt all but the last, does it make sense that a
notification that occurred when only T1 and T2 were waiting is
actually received by Tn at some much later point?
If you consider real predicates attached to those waits then the
scenario described could not arise. Remember that to correctly use
notify() rather than notifyAll(), all threads must be waiting for the
same condition to hold. Given that thread N must release the monitor
before T3 can wait(), then T3 should see a condition that does not
require it to wait. ;-)
David Holmes
David Holmes
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:54 EDT