org.iids.aos.util
Class ConditionVariable

java.lang.Object
  extended by org.iids.aos.util.ConditionVariable

public class ConditionVariable
extends java.lang.Object

Utility class: ConditionVariable


Constructor Summary
ConditionVariable(Mutex lock)
          Constructs a new ConditionVariable object.
 
Method Summary
 void signal()
          Signal one thread waiting on this ConditionVariable.
 void signalAll()
          Signal all threads waiting on this ConditionVariable.
 void waitOn()
          Wait on ConditionVariable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionVariable

public ConditionVariable(Mutex lock)
Constructs a new ConditionVariable object. The lock guards the ConditionVariable.

Parameters:
lock - The lock guarding the ConditionVariable
Method Detail

waitOn

public void waitOn()
            throws java.lang.InterruptedException
Wait on ConditionVariable. This method blocks until the wakeup has been called on this condition variable. The lock guarding this condition variable must have been acquired! After this call returns, the lock will have been acquired again. Note: due to spurious wakeups (which are rare) this method should be called from within a while-loop that checks the condition that should have caused the method waitOn() to return. If the condition has not been satisfied, waitOn() should be called again. E.g. while < !condition > { cv.waitOn(); } The method is interruptible.

Throws:
java.lang.InterruptedException - Acquiring the lock has failed.

signal

public void signal()
Signal one thread waiting on this ConditionVariable. Which thread is woken up is unspecified.


signalAll

public void signalAll()
Signal all threads waiting on this ConditionVariable. The order in which the threads are woken up is unspecified.



Copyright © 2003, 2004 IIDS Group. All Rights Reserved.