public final class AutoCloseableLock extends Object implements AutoCloseable
AutoCloseable interface
so that the close() method will unlock the lock.| 限定符和类型 | 方法和说明 |
|---|---|
static AutoCloseableLock |
acquire(Lock lock)
Acquire the given lock and then wrap it with
AutoCloseableLock
so that the given lock can be released by calling close(),
or by using a try-with-resources statement as shown below. |
static AutoCloseableLock |
acquire(Lock lock,
Runnable preUnlock) |
void |
close()
Unlock the underlying lock.
|
public static AutoCloseableLock acquire(Lock lock)
AutoCloseableLock
so that the given lock can be released by calling close(),
or by using a try-with-resources statement as shown below.
try(AutoCloseableLock acl = AutoCloseableLock.acquire(lock)) {
...
}public static AutoCloseableLock acquire(Lock lock, Runnable preUnlock)
public void close()
close 在接口中 AutoCloseableCopyright © 2017–2021 The Apache Software Foundation. All rights reserved.