Class NoopLock

  • All Implemented Interfaces:
    java.io.Serializable, java.util.concurrent.locks.Lock

    public class NoopLock
    extends java.lang.Object
    implements java.util.concurrent.locks.Lock, java.io.Serializable
    A lock which can always be acquired. It should not be used when a proper lock is required, but it is useful as a performance optimization when locking is not necessary but the code paths have to be shared between the locking and the non-locking variant.
    See Also:
    Serialized Form
    • Method Detail

      • lock

        public void lock()
        Specified by:
        lock in interface java.util.concurrent.locks.Lock
      • lockInterruptibly

        public void lockInterruptibly()
        Specified by:
        lockInterruptibly in interface java.util.concurrent.locks.Lock
      • tryLock

        public boolean tryLock()
        Specified by:
        tryLock in interface java.util.concurrent.locks.Lock
      • tryLock

        public boolean tryLock​(long time,
                               @Nonnull
                               java.util.concurrent.TimeUnit unit)
        Specified by:
        tryLock in interface java.util.concurrent.locks.Lock
      • unlock

        public void unlock()
        Specified by:
        unlock in interface java.util.concurrent.locks.Lock
      • newCondition

        @Nonnull
        public java.util.concurrent.locks.Condition newCondition()
        Specified by:
        newCondition in interface java.util.concurrent.locks.Lock