wait/notifyAll like in Java

Graham St Jack grahams at acres.com.au
Wed Mar 14 19:04:08 PDT 2007


Frank Benoit (keinfarbton) wrote:
> While porting java stuff, i come to this:
> 
> How can I implement a JObject class as a base of all the ported classes
> to have wait/notify/notifyAll with the behaviour like in Java.
> 
> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html
> 
> The "synchronized" of D objects, already uses some monitor.
> Is it possible to access and use it for such an implementation?

We certainly need a way to access the monitor of an object, and hook it
up with condition variables.

I would prefer to explicitly create condition variables (yes, more than
one allowed) in an object, all tied to the object's monitor. The lack of
multiple conditions per object is an issue in Java because you need
complicated schemes involving child objects whenever you need multiple
conditions.

Explicit creation of conditions is appropriate because most objects with
a monitor don't need conditions.

This subject has been coming up on and off for years - can we please get
something added to the runtime (if necessary) and to phobos and tango to
implement conditions in a standard way? The lack of conditions tied to
object monitors is a real pain.



More information about the Digitalmars-d mailing list