Package nxt.util

Class ReadWriteUpdateLock


  • public class ReadWriteUpdateLock
    extends java.lang.Object

    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.