- java.lang.Object
-
- org.eclipse.jetty.util.thread.AutoLock
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.AutoCloseable
- Direct Known Subclasses:
AutoLock.WithCondition
public class AutoLock extends java.lang.Object implements java.lang.AutoCloseable, java.io.SerializableReentrant lock that can be used in a try-with-resources statement.
Typical usage:
try (AutoLock lock = this.lock.lock()) { // Something }- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAutoLock.WithConditionA reentrant lock with a condition that can be used in a try-with-resources statement.
-
Constructor Summary
Constructors Constructor Description AutoLock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanisHeldByCurrentThread()AutoLocklock()Acquires the lock.java.util.concurrent.locks.ConditionnewCondition()
-
-
-
Method Detail
-
lock
public AutoLock 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:
ReentrantLock.isHeldByCurrentThread()
-
newCondition
public java.util.concurrent.locks.Condition newCondition()
- Returns:
- a
Conditionassociated with this lock
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-