public abstract class Lock extends Object implements 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 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 Closeable
close
in interface AutoCloseable
LockReleaseFailedException
- optional specific exception) if
the lock could not be properly released.IOException
public abstract void ensureValid() throws IOException
IOException
- if the lock is no longer valid.Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.