public abstract class Lock
extends java.lang.Object
implements java.io.Closeable
Typical use might look like:
try (final Lock lock = directory.obtainLock("my.lock")) {
// ... code to execute while locked ...
}
Directory.obtainLock(String)| Constructor and Description |
|---|
Lock() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
close()
Releases exclusive access.
|
abstract void |
ensureValid()
Best effort check that this lock is still valid.
|
public abstract void close()
throws java.io.IOException
Note that exceptions thrown from close may require human intervention, as it may mean the lock was no longer valid, or that fs permissions prevent removal of the lock file, or other reasons.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableLockReleaseFailedException - optional specific exception) if
the lock could not be properly released.java.io.IOExceptionpublic abstract void ensureValid()
throws java.io.IOException
java.io.IOException - if the lock is no longer valid.Copyright © 2000–2025 The Apache Software Foundation. All rights reserved.