Package nxt.util
Class ReadWriteUpdateLock
- java.lang.Object
-
- nxt.util.ReadWriteUpdateLock
-
public class ReadWriteUpdateLock extends java.lang.ObjectA read or update lock allows shared access while a write lock enforces exclusive access. Multiple threads can hold the read lock but only one thread can hold the update or write lock. If a thread obtains a lock that it already holds, it must release the lock the same number of times that it obtained the lock.
- An attempt to obtain the read lock while another thread holds the write lock will cause the thread to be suspended until the write lock is released.
- An attempt to obtain the update lock while another thread holds the update or write lock will cause the thread to be suspended until the blocking lock is released. A thread holding the update lock can subsequently obtain the write lock to gain exclusive access. An attempt to obtain the update lock while holding either the read lock or the write lock will result in an exception.
- An attempt to obtain the write lock while another thread holds the read, update or write lock will cause the thread to be suspended until the blocking lock is released. An attempt to obtain the write lock while holding the read lock will result in an exception.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceReadWriteUpdateLock.LockLock interface
-
Constructor Summary
Constructors Constructor Description ReadWriteUpdateLock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadWriteUpdateLock.LockreadLock()Return the read lockReadWriteUpdateLock.LockupdateLock()Return the update lockReadWriteUpdateLock.LockwriteLock()Return the write lock
-
-
-
Method Detail
-
readLock
public ReadWriteUpdateLock.Lock readLock()
Return the read lock- Returns:
- Read lock
-
updateLock
public ReadWriteUpdateLock.Lock updateLock()
Return the update lock- Returns:
- Update lock
-
writeLock
public ReadWriteUpdateLock.Lock writeLock()
Return the write lock- Returns:
- Write lock
-
-