Introduce j.u.c.l.BasicLock

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: 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.

            Assignee:
            Doug Lea
            Reporter:
            Quan Anh Mai
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: