Reentrant lock that can be used in a try-with-resources statement.
Typical usage:
try (AutoLock lock = this.lock.lock())
{
// Something
}
| Modifier and Type | Class and Description |
|---|---|
| public static class | AutoLock.
A reentrant lock with a condition that can be used in a try-with-resources statement. |
| Modifier and Type | Field and Description |
|---|---|
| private final ReentrantLock | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. Closes this resource, relinquishing any underlying resources. |
| public boolean | |
| pack-priv boolean | |
| public AutoLock | |
| public Condition | |
| public AutoLock |
| _lock | back to summary |
|---|---|
| private final ReentrantLock _lock | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID
| |
| AutoLock | back to summary |
|---|---|
| public AutoLock() | |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this resource, relinquishing any underlying resources.
This method is invoked automatically on objects managed by the
| |
| isHeldByCurrentThread | back to summary |
|---|---|
public boolean isHeldByCurrentThread()
| |
| isLocked | back to summary |
|---|---|
| pack-priv boolean isLocked() | |
| lock | back to summary |
|---|---|
| public AutoLock lock() Acquires the lock.
| |
| newCondition | back to summary |
|---|---|
| public Condition newCondition() | |
| tryLock | back to summary |
|---|---|
| public AutoLock tryLock() Tries to acquire the lock. Whether the lock was acquired can be tested
with Typical usage of this method is in
| |
A reentrant lock with a condition that can be used in a try-with-resources statement.
Typical usage:
// Waiting
try (AutoLock lock = _lock.lock())
{
lock.await();
}
// Signaling
try (AutoLock lock = _lock.lock())
{
lock.signalAll();
}
| Modifier and Type | Field and Description |
|---|---|
| private final Condition |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | |
| public AutoLock. | |
| public void | |
| public void | |
| public AutoLock. |
| _condition | back to summary |
|---|---|
| private final Condition _condition | |
| WithCondition | back to summary |
|---|---|
| public WithCondition() | |
| await | back to summary |
|---|---|
public void await() throws InterruptedException
| |
| await | back to summary |
|---|---|
public boolean await(long time, TimeUnit unit) throws InterruptedException
| |
| lock | back to summary |
|---|---|
| public AutoLock. Overrides org. Doc from org. Acquires the lock.
| |
| signal | back to summary |
|---|---|
public void signal()
| |
| signalAll | back to summary |
|---|---|
public void signalAll()
| |
| tryLock | back to summary |
|---|---|
| public AutoLock. Overrides org. Doc from org. Tries to acquire the lock. Whether the lock was acquired can be tested
with Typical usage of this method is in
| |