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

Introduce j.u.c.l.BasicLock

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      Introduce a basic Lock implementation that does not allow reentrancy. A BasicLock has similar behaviours as those of a ReentrantLock apart from the reentrancy property. My reasons are:

      - It is the most basic form of a Lock, and it is what most Lock usages are about. Currently, we only have ReentrantLock, which imposes an unnecessary reentrancy property for many usages.

      - A non-recursive lock is easier to reason about, as Lock::lock can only transit the lock from the unlock state to the lock state, and Lock::unlock can only do the opposite. This is in contrast to ReentrantLock, of which a lock or an unlock invocation can have 2 possible state transitions. This easily makes reasoning about the operation of a ReentrantLock non-local.

      - A non-recursive lock can be more performant since it does not have to take into consideration reentrancy.

            Unassigned Unassigned
            qamai Quan Anh Mai
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: