public final class AutoReadWriteLock extends Object implements ReadWriteLock
ReadWriteLock
that can return AutoLock
s and exposes
autoReadLock()
and autoWriteLock()
like AutoLock.autoLock()
.
ReadWriteLock lock = ...;
...
AutoReadWriteLock autoLock = new AutoReadWriteLock(lock);
// Not locked
try (AutoLock al = autoLock.autoReadLock()) { // variable required but unused
// Locked
...
}
// Not locked
Constructor and Description |
---|
AutoReadWriteLock()
Manages a new
ReentrantReadWriteLock . |
AutoReadWriteLock(ReadWriteLock lock) |
Modifier and Type | Method and Description |
---|---|
AutoLock |
autoReadLock() |
AutoLock |
autoWriteLock() |
AutoLock |
readLock() |
String |
toString() |
AutoLock |
writeLock() |
public AutoReadWriteLock()
ReentrantReadWriteLock
.public AutoReadWriteLock(ReadWriteLock lock)
lock
- lock to managepublic AutoLock readLock()
readLock
in interface ReadWriteLock
public AutoLock writeLock()
writeLock
in interface ReadWriteLock
public AutoLock autoReadLock()
ReadWriteLock.readLock()
, lockedpublic AutoLock autoWriteLock()
ReadWriteLock.writeLock()
()}, lockedCopyright © 2014–2018. All rights reserved.