Package nxt.util
Class ReadWriteUpdateLock
java.lang.Object
nxt.util.ReadWriteUpdateLock
A 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreadLock()Return the read lockReturn the update lockReturn the write lock
-
Constructor Details
-
ReadWriteUpdateLock
public ReadWriteUpdateLock()
-
-
Method Details
-
readLock
Return the read lock- Returns:
- Read lock
-
updateLock
Return the update lock- Returns:
- Update lock
-
writeLock
Return the write lock- Returns:
- Write lock
-