protected class ReentrantLock.ReadLock extends ReentrantLock.Lock
lockCountManager, waitersForLock| Modifier | Constructor and Description |
|---|---|
protected |
ReadLock(LockCountManager<? super T> lockCountManager)
Creates a new read lock using the designated
LockCountManager for comparing objects. |
| Modifier and Type | Method and Description |
|---|---|
void |
lock(T object,
long timeout)
Provides the designated object with a read lock.
|
protected boolean |
notificationRequired()
Gets whether a notification of waiting threads is required.
|
boolean |
unlock(T object)
Additionally notify the writers waiting for readers on the write lock.
|
currentLockingObject, hasLock, isLocked, lock, objectsWaitingToLockprotected ReadLock(LockCountManager<? super T> lockCountManager)
LockCountManager for comparing objects.lockCountManager - The manager counting locks for objects.public void lock(T object, long timeout) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
Since the lock is reentrant, an object may acquire a lock multiple times. But it also has to release the lock per acquisition afterwards.
lock in class ReentrantLock.Lockobject - The object that requests a read lock.timeout - The time to wait for the lock. A timeout <= 0 means to
wait forever (or until the lock is granted).java.lang.InterruptedException - If the thread is interrupted while waiting
for the lock, an InterruptedException will be
thrown.java.util.concurrent.TimeoutException - If the designated timeout elapsed before the
lock can be acquired, a TimeoutException will be
thrown.public boolean unlock(T object)
unlock in class ReentrantLock.Lockobject - The object for which the lock should be released.false will be returned.protected boolean notificationRequired()
notificationRequired in class ReentrantLock.Lock