Class java.util.ConditionLock
All Packages This Package Previous Next
Class java.util.ConditionLock
java.lang.Object
|
+----java.util.Lock
|
+----java.util.ConditionLock
-
public final class
ConditionLock
-
extends Lock
ConditionLock is a Lock with a built in state variable. This class
provides the ability to wait for the state variable to be set to a
desired value and then acquire the lock.
The lockWhen() and unlockWith() methods can be safely intermixed
with the lock() and unlock() methods. However if there is a thread
waiting for the state variable to become a particular value and you
simply call Unlock(), that thread will not be able to acquire the
lock until the state variable equals its desired value.
-
Version:
-
1.7, 31 Jan 1995
-
Author:
-
Peter King
-
ConditionLock()
-
Creates a ConditionLock.
-
ConditionLock(int)
-
Creates a ConditionLock in an initialState.
-
lockWhen(int)
-
Acquires the lock when the state variable equals the desired
state.
-
unlockWith(int)
-
Releases the lock, and sets the state to a new value.
ConditionLock
public ConditionLock()
-
Creates a ConditionLock.
ConditionLock
public ConditionLock(int initialState)
-
Creates a ConditionLock in an initialState.
lockWhen
public synchronized void lockWhen(int desiredState)
-
Acquires the lock when the state variable equals the desired
state.
-
Parameters:
-
desiredState
-
the desired state
unlockWith
public synchronized void unlockWith(int newState)
-
Releases the lock, and sets the state to a new value.
-
Parameters:
-
newState
-
the new state
All Packages This Package Previous Next