public interface LockFile
file
.
An instance is acquired by invoking LockFileFactory.acquire(File, long)
.
All methods of this interface are thread-safe.
Modifier and Type | Method and Description |
---|---|
InputStream |
createInputStream() |
OutputStream |
createOutputStream() |
File |
getFile()
Gets the underlying file being locked.
|
Lock |
getLock() |
void |
release()
Releases the lock.
|
File getFile()
null
.void release()
Important: This method must be called exactly once for every LockFile
instance!
It is highly recommended to use a try-finally-block:
LockFile lockFile = LockFileFactory.acquire(theFile, theTimeout); try { // do something } finally { lockFile.release(); }
This method is thread-safe and thus might be invoked on a different thread than the instance
was created. However, it must be invoked exactly once (per LockFile
instance).
IllegalStateException
- if this method is invoked more than once on the same instance.LockFileFactory.acquire(File, long)
InputStream createInputStream() throws IOException
IOException
OutputStream createOutputStream() throws IOException
IOException
Copyright © 2013-2014. All Rights Reserved.