public interface FileLocker
Provides process-level file locking. Locking is advisory, meaning that processes must
cooperatively use the same locking mechanism.
-
Method Summary
Modifier and TypeMethodDescriptionvoidlock()Equivalent to {lock(long)with a timeout argument of 10000 milliseconds.voidlock(long timeout) Attempt to lock the file associated with this locker object.voidrelease()Release the lock if acquired.
-
Method Details
-
lock
Equivalent to {lock(long)with a timeout argument of 10000 milliseconds.- Throws:
LockTimeoutException
-
lock
Attempt to lock the file associated with this locker object. Note that technically, not the file itself is locked, but an empty marker file next to it.- Parameters:
timeout- timeout in milliseconds- Throws:
LockTimeoutException- if lock cannot be obtained for more than the specified timeout in millseconds.
-
release
void release()Release the lock if acquired. Also removes the lock marker file.
-