nxt.util

## Class ReadWriteUpdateLock

- java.lang.Object
- - nxt.util.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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `ReadWriteUpdateLock.Lock` Lock interface

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReadWriteUpdateLock()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ReadWriteUpdateLock.Lock` | `readLock()` Return the read lock
    `ReadWriteUpdateLock.Lock` | `updateLock()` Return the update lock
    `ReadWriteUpdateLock.Lock` | `writeLock()` Return the write lock

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ReadWriteUpdateLock

          public ReadWriteUpdateLock()

  - ### 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