public class ReadWriteLockNamedLock extends NamedLockSupport
ReadWriteLock
instances. The adapted lock MUST SUPPORT
reentrancy, non re-entrant locks will NOT work. It is the responsibility of an adapting lock, to ensure that
above lock requirement stands.logger
Constructor and Description |
---|
ReadWriteLockNamedLock(String name,
NamedLockFactorySupport factory,
ReadWriteLock readWriteLock) |
Modifier and Type | Method and Description |
---|---|
boolean |
lockExclusively(long time,
TimeUnit unit)
Tries to lock exclusively, may block for given time.
|
boolean |
lockShared(long time,
TimeUnit unit)
Tries to lock shared, may block for given time.
|
void |
unlock()
Unlocks the lock, must be invoked by caller after one of the
NamedLock.lockShared(long, TimeUnit) or NamedLock.lockExclusively(long, TimeUnit) . |
close, name
public ReadWriteLockNamedLock(String name, NamedLockFactorySupport factory, ReadWriteLock readWriteLock)
public boolean lockShared(long time, TimeUnit unit) throws InterruptedException
NamedLock
true
.InterruptedException
public boolean lockExclusively(long time, TimeUnit unit) throws InterruptedException
NamedLock
true
.InterruptedException
public void unlock()
NamedLock
NamedLock.lockShared(long, TimeUnit)
or NamedLock.lockExclusively(long, TimeUnit)
.Copyright © 2010–2021 The Apache Software Foundation. All rights reserved.