org.progeeks.util.thread
Class ConditionalLock

java.lang.Object
  extended by org.progeeks.util.thread.ConditionalLock

public class ConditionalLock
extends java.lang.Object

Allows a thread to pause waiting for a state set by another thread.

Version:
$Revision: 1.1 $
Author:
Paul Speed

Constructor Summary
ConditionalLock()
          Creates a new conditional in the default state of false.
ConditionalLock(boolean state)
          Creates a new conditional in the specified state.
 
Method Summary
 boolean isTrue()
          Returns true if the conditional currently represents a true state.
 void setFalse()
          Sets the conditional to the false state.
 void setState(boolean state)
          Sets the state to the specified value.
 void setTrue()
          Sets the conditional to the true state.
 void waitForFalse()
          Waits for the state to become false.
 void waitForFalse(long timeout)
          Waits for the state to become false for the specified milliseconds.
 void waitForTrue()
          Waits for the state to become true.
 void waitForTrue(long timeout)
          Waits for the state to become true for the specified milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionalLock

public ConditionalLock()
Creates a new conditional in the default state of false.


ConditionalLock

public ConditionalLock(boolean state)
Creates a new conditional in the specified state.

Method Detail

isTrue

public boolean isTrue()
Returns true if the conditional currently represents a true state.


setFalse

public void setFalse()
Sets the conditional to the false state.


setTrue

public void setTrue()
Sets the conditional to the true state.


setState

public void setState(boolean state)
Sets the state to the specified value.


waitForTrue

public void waitForTrue(long timeout)
                 throws java.lang.InterruptedException
Waits for the state to become true for the specified milliseconds.

Throws:
java.lang.InterruptedException

waitForTrue

public void waitForTrue()
                 throws java.lang.InterruptedException
Waits for the state to become true.

Throws:
java.lang.InterruptedException

waitForFalse

public void waitForFalse(long timeout)
                  throws java.lang.InterruptedException
Waits for the state to become false for the specified milliseconds.

Throws:
java.lang.InterruptedException

waitForFalse

public void waitForFalse()
                  throws java.lang.InterruptedException
Waits for the state to become false.

Throws:
java.lang.InterruptedException


Copyright © 2002-2003 Paul Speed. All Rights Reserved.