public static interface ReadWriteThreadLock.Lock
Modifier and Type | Method and Description |
---|---|
void |
lock()
Acquires the lock, blocking to wait until the lock can be acquired.
|
boolean |
tryLock(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Tries acquiring the lock, blocking to wait until the lock can be acquired or the
specified time has passed, then returns
true in the first case and false
in the second case. |
void |
unlock()
Releases the lock.
|
void lock()
If the thread executing this method is interrupted, this method will throw a runtime exception.
boolean tryLock(long timeout, @NonNull java.util.concurrent.TimeUnit timeUnit)
true
in the first case and false
in the second case.
If the thread executing this method is interrupted, this method will throw a runtime exception.
This method will try acquiring the lock first before checking for timeout. A
non-positive timeout means the method will return immediately after the first try. This
behavior is similar to a ReentrantReadWriteLock
.
timeout
- the maximum time to wait for the locktimeUnit
- the unit of the timeouttrue
if the lock was acquiredvoid unlock()