com.lti.utils.synchronization
Class SynchronizedBoolean

java.lang.Object
  extended by com.lti.utils.synchronization.SynchronizedBoolean

public class SynchronizedBoolean
extends java.lang.Object

Useful class for setting a flag between threads. For simple uses, this class is not that useful, since boolean access is guaranteed to be atomic.

Author:
Ken Larson

Constructor Summary
SynchronizedBoolean()
           
SynchronizedBoolean(boolean initValue)
           
 
Method Summary
 boolean getAndSet(boolean oldValue, boolean newValue)
          If the value is oldValue, set to newValue and return true, otherwise return false.
 boolean getValue()
           
 void setValue(boolean newValue)
           
 void waitUntil(boolean value)
           
 boolean waitUntil(boolean value, int timeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizedBoolean

public SynchronizedBoolean()

SynchronizedBoolean

public SynchronizedBoolean(boolean initValue)
Method Detail

getValue

public boolean getValue()

setValue

public void setValue(boolean newValue)

waitUntil

public void waitUntil(boolean value)
               throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

waitUntil

public boolean waitUntil(boolean value,
                         int timeout)
                  throws java.lang.InterruptedException
Returns:
true if value matches value, false if timeout occurred
Throws:
java.lang.InterruptedException

getAndSet

public boolean getAndSet(boolean oldValue,
                         boolean newValue)
If the value is oldValue, set to newValue and return true, otherwise return false.