Class Locker


  • public class Locker
    extends java.lang.Object

    Convenience auto closeable ReentrantLock wrapper.

     try (Locker.Lock lock = locker.lock())
     {
       // something
     }
     
    • Constructor Detail

      • Locker

        public Locker()
    • Method Detail

      • lock

        public Locker.Lock lock()

        Acquires the lock.

        Returns:
        the lock to unlock
      • lockIfNotHeld

        @Deprecated
        public Locker.Lock lockIfNotHeld()
        Deprecated.
        use lock() instead
        Returns:
        the lock to unlock
      • isLocked

        public boolean isLocked()
        Returns:
        whether this lock has been acquired
      • newCondition

        public java.util.concurrent.locks.Condition newCondition()
        Returns:
        a Condition associated with this lock