Secure iNet Factory

com.jscape.util
Class BooleanLock

java.lang.Object
  extended by com.jscape.util.BooleanLock

public final class BooleanLock
extends java.lang.Object

The boolean lock. Used for thread synchronization.

Version:
1.0
Author:
Alex Usun

Field Summary
static int INFINITE_TIMEOUT
          The infinite timeout value.
 
Constructor Summary
BooleanLock()
          Creates a new lock instance initialized with false value.
BooleanLock(boolean initialValue)
          Creates a new lock instance.
 
Method Summary
 boolean isFalse()
          Checks if the current lock value is false.
 boolean isTrue()
          Checks if the current lock value is true.
 void setValue(boolean newValue)
          Sets value to the lock.
 boolean testAndSet(boolean value)
           
 boolean waitToSetFalse()
          Waits until the lock value is true and sets it to false.
 boolean waitToSetFalse(long msTimeout)
          Waits until the lock value is true and sets it to false.
 boolean waitToSetTrue()
          Waits until the lock value is false and sets it to true.
 boolean waitToSetTrue(long msTimeout)
          Waits until the lock value is false and sets it to true.
 boolean waitUntilFalse()
          Waits until the lock value is false.
 boolean waitUntilFalse(long msTimeout)
          Waits until the lock value is false.
 boolean waitUntilStateIs(boolean state)
          Waits until the lock value is in specified state.
 boolean waitUntilStateIs(boolean state, long msTimeout)
          Waits until the lock value is in specified state.
 boolean waitUntilTrue()
          Waits until the lock value is true.
 boolean waitUntilTrue(long msTimeout)
          Waits until the lock value is true.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFINITE_TIMEOUT

public static final int INFINITE_TIMEOUT
The infinite timeout value.

See Also:
Constant Field Values
Constructor Detail

BooleanLock

public BooleanLock(boolean initialValue)
Creates a new lock instance.

Parameters:
initialValue - the initial value

BooleanLock

public BooleanLock()
Creates a new lock instance initialized with false value.

Method Detail

isTrue

public boolean isTrue()
Checks if the current lock value is true.

Returns:
true if the lock value is true; false otherwise

isFalse

public boolean isFalse()
Checks if the current lock value is false.

Returns:
true if the lock value is false; false otherwise

setValue

public void setValue(boolean newValue)
Sets value to the lock.

Parameters:
newValue - the new value

waitToSetTrue

public boolean waitToSetTrue(long msTimeout)
Waits until the lock value is false and sets it to true.

Parameters:
msTimeout - the timeout value
Returns:
true if lock value is set to true; false if timeout occurs

waitToSetTrue

public boolean waitToSetTrue()
Waits until the lock value is false and sets it to true.

Returns:
true if lock value is set to true; false if timeout occurs

waitToSetFalse

public boolean waitToSetFalse(long msTimeout)
Waits until the lock value is true and sets it to false.

Parameters:
msTimeout - the timeout value
Returns:
true if lock value is set to false; false if timeout occurs

waitToSetFalse

public boolean waitToSetFalse()
Waits until the lock value is true and sets it to false.

Returns:
true if lock value is set to false; false if timeout occurs

waitUntilTrue

public boolean waitUntilTrue(long msTimeout)
Waits until the lock value is true.

Parameters:
msTimeout - the timeout value
Returns:
true if lock value is set to true; false if timeout occurs

waitUntilTrue

public boolean waitUntilTrue()
Waits until the lock value is true.

Returns:
true if lock value is set to true; false if timeout occurs

waitUntilFalse

public boolean waitUntilFalse(long msTimeout)
Waits until the lock value is false.

Parameters:
msTimeout - the timeout value
Returns:
true if lock value is set to false; false if timeout occurs

waitUntilFalse

public boolean waitUntilFalse()
Waits until the lock value is false.

Returns:
true if lock value is set to false; false if timeout occurs

waitUntilStateIs

public boolean waitUntilStateIs(boolean state,
                                long msTimeout)
Waits until the lock value is in specified state.

Parameters:
state - the target state
msTimeout - the timeout value
Returns:
true if lock value is set to the specified state; false if timeout occurs

waitUntilStateIs

public boolean waitUntilStateIs(boolean state)
Waits until the lock value is in specified state.

Parameters:
state - the target state
Returns:
true if lock value is set to the specified state; false if timeout occurs

testAndSet

public boolean testAndSet(boolean value)

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved