wait/notifyAll like in Java

BLS Killing_Zoe at web.de
Thu Mar 1 12:34:45 PST 2007


Frank Benoit (keinfarbton) schrieb:
> 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?

Hi Frank,
probabely this hint is simply shi* but
I suggest to have a look on Dough Leas concurrent library at :

http://g.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html

  The package mainly consists of implementations of a few interfaces:

     * Sync -- locks, conditions
     * Channel -- queues, buffers
     * Barrier -- multi-party synchronization
     * SynchronizedVariable -- atomic ints, refs etc
      * Executor -- replacements for direct use of Thread

wait() is AFAIK implemented
try
    {
      while (true)
        lock.wait();
    }
  catch (InterruptedException e)
    {
    }

HTH and Sorry in case that I miss something. ;-)
Bjoern



More information about the Digitalmars-d mailing list