Class Locker


  • public class Locker
    extends java.lang.Object
    Convenience Lock Wrapper.
     try(Locker.Lock lock = locker.lock())
     {
       // something
     }
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  Locker.Lock
      The unlocker object that unlocks when it is closed.
    • Constructor Summary

      Constructors 
      Constructor Description
      Locker()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isLocked()  
      Locker.Lock lock()
      Acquires the lock.
      java.util.concurrent.locks.Condition newCondition()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Locker

        public Locker()
    • Method Detail

      • lock

        public Locker.Lock lock()
        Acquires the lock.
        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