public final class KeyedLock<T>
extends java.lang.Object
Constructor | Description |
---|---|
KeyedLock() |
Creates a non-fair lock
|
KeyedLock(boolean fair) |
Creates a new lock
|
Modifier and Type | Method | Description |
---|---|---|
Releasable |
acquire(T key) |
Acquires a lock for the given key.
|
boolean |
hasLockedKeys() |
Returns
true if this lock has at least one locked key. |
boolean |
isHeldByCurrentThread(T key) |
Returns
true iff the caller thread holds the lock for the given key |
public KeyedLock(boolean fair)
fair
- Use fair locking, ie threads get the lock in the order they requested itpublic KeyedLock()
public Releasable acquire(T key)
Releasable
.public boolean isHeldByCurrentThread(T key)
true
iff the caller thread holds the lock for the given keypublic boolean hasLockedKeys()
true
if this lock has at least one locked key.