Class AutoLock

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class AutoLock
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Reentrant lock that can be used in a try-with-resources statement.
     try (AutoLock lock = this.lock.lock())
     {
         // Something
     }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      AutoLock()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      AutoLock 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

      • AutoLock

        public AutoLock()
    • Method Detail

      • lock

        public AutoLock lock()

        Acquires the lock.

        Returns:
        this AutoLock for unlocking
      • newCondition

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

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable