JavaMemoryModel: Wait/notify semantics

From: Bill Pugh (
Date: Mon Jan 19 2004 - 15:21:49 EST

As we are finalizing the public draft document, I just want to review
the status of the wait/notify semantics, since there has been a lot
of email on it. These semantics are a change from the community
review draft.

Basically, we do not allow lost notifications or interrupts. However,
we do allow spurious wakeups from wait.

* ordering: If a thread is both notified and interrupted while waiting, it
   may either:
   - return normally from wait, while still having a pending interrupt
     (in other works, a call to Thread.interrupted() would return true)
   - return from wait by throwing an InterruptedException
   It may not:
   - return normally from the call to wait, having swallowed the interrupt.

* We forbid lost notifications due to interrupts: Assume that a set S
of threads
   is in the wait set of a monitor M, and another thread performs a notify on M.
   Then either
   * at least one thread in S must return normally from wait (i.e., not throw
     InterruptedException), or
   * all of the threads in S must exit wait by throwing InterruptedException

* A call to wait may return normally at any time (a spurious wakeup). Spurious
   wake-ups are allowed because standard techniques for avoiding lost
   notifications in the face of interrupts.

Any objections?

JavaMemoryModel mailing list -

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