JDK-4403899 : RFE: Object class needs notify(Thread t) method
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-01-11
  • Updated: 2002-04-27
  • Resolved: 2002-04-27
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 01/11/2001


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


There are a number of occasions where the notify() and notifyAll()
methods on Object have proven insufficient for effecient threaded
use. Specifically, in some instances the order in which threads wait()
on an object may be important to an application - generally the longest
waiting thread may be the one which the author wants to notify.

In particular, the notify() method wakes up *one* waiting thread -
but gives the caller no ability to specify which thread is to be woken. The
use of the notifyAll() method together with some check-and-rewait thread
logic is a workaround, but this becomes very inefficient where large numbers
of threads are waiting on an object. Calling suspend() and resume() onthe
threads is not an alternative to wait/notify as these methods are deprecated.

Given that a class author may know which thread he wishes to notify, the
addition of a notify (Thread t) to the Object class would be a
particular benefit for multi-threaded classes. The method could take no action
(or possibly throw an exception) if the specified Thread was not wait()ing
in the instance.
(Review ID: 114970) 
======================================================================

Comments
EVALUATION There are patterns for "specific notification." (See Doug Lea's "Concurrent Programming in Java" for details.) That said, platform support would be desirable. Luckily, the concurrency libraries resulting from JSR-166 will provide this support. ###@###.### 2002-04-27
27-04-2002