Class LockCloseable

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class LockCloseable
    extends java.lang.Object
    implements java.lang.AutoCloseable
    AutoCloseable wrapper for Lock that enables try-with-resources usage.
    • Constructor Summary

      Constructors 
      Constructor Description
      LockCloseable​(java.util.concurrent.locks.Lock lock)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      LockCloseable lock()
      Locks the underlying lock and returns this instance for use in try-with-resources.
      • Methods inherited from class java.lang.Object

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

      • LockCloseable

        public LockCloseable​(java.util.concurrent.locks.Lock lock)
    • Method Detail

      • lock

        public LockCloseable lock()
        Locks the underlying lock and returns this instance for use in try-with-resources.
        Returns:
        this LockCloseable instance
      • close

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