JDK-4308396 : Java wait/notify should require condition variable, allow spurious wakeups
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2000-01-31
  • Updated: 2003-11-23
  • Resolved: 2003-11-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b30Fixed
Related Reports
Relates :  
Relates :  
Description

Name: mt13159			Date: 01/30/2000


The current Java Language Specification definition of wait, notify,
   and notifyAll does not require that they be done within a "condition
   variable" paradigm.  The requested change would be to require that
   wait be called from within a loop that tests for a logical condition
   variable, and that notify and notifyAll change the value of that
   condition variable, and that when wait returns the value of the condition 
   variable must be checked to see that it has changed, otherwise the
   loop continues and the wait is reentered.  A corollary of the requested 
   change is that waits may return due to spurious wakeups, meaning operating
   system events unconnected to any action within the Java program.

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger tiger-beta FIXED IN: tiger-beta INTEGRATED IN: tiger-b30 tiger-beta
14-06-2004

EVALUATION The spec should and will be clarified to indicate that spurious wakeups can occur. This is one of the many reasons that wait should *always* be used inside a loop (See Item 50 in Bloch's "Effective Java.") Note that this does not affect the JLS, which no longer contains the specifications for the core libraries. It will affect only the documentation of the Object.wait method. ###@###.### 2003-01-21 I applaud the proposed change to the specification, but HotSpot JVM implementors should be aware that for compatibility reaons our _implementation_ is not permitted to return spuriously from wait(). ###@###.### 2003-10-07
07-10-2003