Interface FileLocker


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 Type
    Method
    Description
    void
    Equivalent to {lock(long) with a timeout argument of 10000 milliseconds.
    void
    lock(long timeout)
    Attempt to lock the file associated with this locker object.
    void
    Release the lock if acquired.
  • Method Details

    • lock

      void lock() throws LockTimeoutException
      Equivalent to {lock(long) with a timeout argument of 10000 milliseconds.
      Throws:
      LockTimeoutException
    • lock

      void lock(long timeout) throws LockTimeoutException
      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.