Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8195628

Documentation for lock(), trylock(), lockInterruptibly​() of ReentrantReadWriteLock.WriteLock needs to be corrected

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 7u151, 8u144, 9
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None

      Description

      The API documentation for lock(), tryLock() and lockInterruptibly​() methods of ReentrantReadWriteLock.WriteLock states that the write lock can not be acquired if the read lock is held by another thread. Instead it should clearly state that the write lock can not be acquired even if the read lock is held by the current thread.

      https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.WriteLock.html#tryLock--


      This point is clarified in the 'Reentrancy' section of this page:
      https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html

      "Additionally, a writer can acquire the read lock, but not vice-versa. Among other applications, reentrancy can be useful when write locks are held during calls or callbacks to methods that perform reads under read locks. If a reader tries to acquire the write lock it will never succeed. "

        Attachments

          Activity

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              poonam Poonam Bajaj Parhar
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: