|
|||||||||
| Home >> All >> com >> flexstor >> common >> [ threadmgr overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.flexstor.common.threadmgr
Class BooleanLock

java.lang.Objectcom.flexstor.common.threadmgr.BooleanLock
- public class BooleanLock
- extends java.lang.Object
Useful class to hide away all the implementation of a locking mechanism using wait()/notifyAll() This class makes missed notifications impossible and provides an interruptible, timeout-capable, technique for providing exclusive access to a block of code.
| Field Summary | |
private boolean |
value
|
| Constructor Summary | |
BooleanLock()
Sets the initial value of the lock to false. |
|
BooleanLock(boolean initialValue)
Sets the value of the lock to an initial state. |
|
| Method Summary | |
boolean |
isFalse()
Returns true if lock is set to false, false otherwise. |
boolean |
isTrue()
Returns true if lock is set to true, false, otherwise. |
void |
setValue(boolean newValue)
If current lock's value is different from newValue, sets it to newValue and notifies other threads of this change. |
boolean |
waitToSetFalse()
Waits until it can set the lock to false. |
boolean |
waitToSetFalse(long msTimeout)
Waits up to msTimeOut milliseconds to set the lock to false. |
boolean |
waitToSetTrue()
Waits until it can set the lock to true. |
boolean |
waitToSetTrue(long msTimeout)
Waits up to msTimeOut milliseconds to set the lock to true. |
boolean |
waitUntilFalse()
Waits until lock is false. |
boolean |
waitUntilFalse(long msTimeout)
Waits up to msTimeOut milliseconds until another thread sets the lock to false. |
boolean |
waitUntilStateIs(boolean state)
Waits until lock is set to state by another thread. |
boolean |
waitUntilStateIs(boolean state,
long msTimeout)
Waits up to msTimeOut milliseconds until another thread sets the lock to the state being checked. |
boolean |
waitUntilTrue()
Waits until lock is true. |
boolean |
waitUntilTrue(long msTimeout)
Waits up to msTimeOut milliseconds until another thread sets the lock to true. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
value
private boolean value
| Constructor Detail |
BooleanLock
public BooleanLock(boolean initialValue)
- Sets the value of the lock to an initial state.
BooleanLock
public BooleanLock()
- Sets the initial value of the lock to false.
| Method Detail |
setValue
public void setValue(boolean newValue)
- If current lock's value is different from newValue, sets it to newValue
and notifies other threads of this change.
waitToSetTrue
public boolean waitToSetTrue()
throws java.lang.InterruptedException
- Waits until it can set the lock to true.
It first waits until it has exclusive access and the lock is false.
waitToSetTrue
public boolean waitToSetTrue(long msTimeout)
throws java.lang.InterruptedException
- Waits up to msTimeOut milliseconds to set the lock to true.
It first waits until it has exclusive access and the lock is false.
waitToSetFalse
public boolean waitToSetFalse()
throws java.lang.InterruptedException
- Waits until it can set the lock to false.
It first waits until it has exclusive access and the lock is true.
waitToSetFalse
public boolean waitToSetFalse(long msTimeout)
throws java.lang.InterruptedException
- Waits up to msTimeOut milliseconds to set the lock to false.
It first waits until it has exclusive access and the lock is true.
isTrue
public boolean isTrue()
- Returns true if lock is set to true, false, otherwise.
isFalse
public boolean isFalse()
- Returns true if lock is set to false, false otherwise.
waitUntilTrue
public boolean waitUntilTrue()
throws java.lang.InterruptedException
- Waits until lock is true.
waitUntilTrue
public boolean waitUntilTrue(long msTimeout)
throws java.lang.InterruptedException
- Waits up to msTimeOut milliseconds until another thread sets the lock to true.
waitUntilFalse
public boolean waitUntilFalse()
throws java.lang.InterruptedException
- Waits until lock is false.
waitUntilFalse
public boolean waitUntilFalse(long msTimeout)
throws java.lang.InterruptedException
- Waits up to msTimeOut milliseconds until another thread sets the lock to false.
waitUntilStateIs
public boolean waitUntilStateIs(boolean state)
throws java.lang.InterruptedException
- Waits until lock is set to state by another thread.
waitUntilStateIs
public boolean waitUntilStateIs(boolean state,
long msTimeout)
throws java.lang.InterruptedException
- Waits up to msTimeOut milliseconds until another thread sets the lock to the state
being checked.
|
|||||||||
| Home >> All >> com >> flexstor >> common >> [ threadmgr overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.flexstor.common.threadmgr.BooleanLock