Package org.eclipse.jetty.util.thread
Class AutoLock
java.lang.Object
org.eclipse.jetty.util.thread.AutoLock
- All Implemented Interfaces:
Serializable
,AutoCloseable
- Direct Known Subclasses:
AutoLock.WithCondition
Reentrant lock that can be used in a try-with-resources statement.
Typical usage:
try (AutoLock lock = this.lock.lock()) { // Something }
- See Also:
-
Constructor Details
-
AutoLock
public AutoLock()
-
-
Method Details
-
lock
Acquires the lock.
- Returns:
- this AutoLock for unlocking
-
isHeldByCurrentThread
public boolean isHeldByCurrentThread()- Returns:
- whether this lock is held by the current thread
- See Also:
-
newCondition
- Returns:
- a
Condition
associated with this lock
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-