com.holub.asynch
Class ConditionVariable

java.lang.Object
  extended by com.holub.asynch.ConditionVariable

public class ConditionVariable
extends Object

This class is a simplified version of the com.asynch.Condition class described in Taming Java Threads. It's really supplanted by classes in the Java 1.5 java.util.concurrent package. Use it to wait for some condition to become true. For example:

        ConditionVariable hellFreezesOver = new ConditionVariable(false);

        Thread 1:
                hellFreezesOver.waitForTrue();

        Thread 2:
                hellFrezesOver.set(true);
        
Unlike wait() you will not be suspened at all if you wait on a true condition variable. Call set(false), to put the variable back into a false condition (thereby forcing threads to wait for the condition to become true, again).


Constructor Summary
ConditionVariable(boolean isTrue)
           
 
Method Summary
 boolean isTrue()
           
 void set(boolean how)
           
 void waitForTrue()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionVariable

public ConditionVariable(boolean isTrue)
Method Detail

isTrue

public boolean isTrue()

set

public void set(boolean how)

waitForTrue

public final void waitForTrue()
                       throws InterruptedException
Throws:
InterruptedException