Interface NamedLock

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
AdaptedSemaphoreNamedLock, CompositeNamedLock, FileLockNamedLock, NamedLockSupport, ReadWriteLockNamedLock

public interface NamedLock extends AutoCloseable
A named lock, functionally similar to existing JVM and other implementations. Must support boxing (reentrancy), but no lock upgrade is supported. The lock instance obtained from lock factory must be treated as a resource, best in try-with-resource block. Usual pattern to use this lock:
   try (NamedLock lock = factory.getLock("resourceName")) {
     if (lock.lockExclusively(10L, Timeunit.SECONDS)) {
       try {
         ... exclusive access to "resourceName" resource gained here
       }
       finally {
         lock.unlock();
       }
     }
     else {
       ... failed to gain access within specified time, handle it
     }
   }