Interface SharedMutex

All Superinterfaces:
AutoCloseable, Closeable

public interface SharedMutex extends Closeable
A mutually exclusive lock, which may or may not be reentrant.
Author:
Christian Kohlschütter
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Reports if this lock instance can safely be accessed from multiple processes, or not.
    boolean
    Reports if this lock instance is re-entrant, or not.
    boolean
    tryLock(int timeoutMillis)
    Try to lock the mutex.
    void
    Unlocks the mutex.

    Methods inherited from interface Closeable

    close
  • Method Details

    • tryLock

      boolean tryLock(int timeoutMillis) throws IOException
      Try to lock the mutex.

      Note that unless isReentrant() is , trying to lock the mutex a second time will not succeed until someone else calls unlock()

      Parameters:
      timeoutMillis - The timeout, in milliseconds, or 0 for "try indefinitely".
      Returns:
      true if the lock was acquired.
      Throws:
      IOException - on error.
    • unlock

      void unlock() throws IOException
      Unlocks the mutex.

      By default, no ownership checks are performed.

      Throws:
      IOException - on error.
    • isReentrant

      boolean isReentrant()
      Reports if this lock instance is re-entrant, or not.

      The value returned is constant.

      Returns:
      true if reentrant.
    • isInterProcess

      boolean isInterProcess()
      Reports if this lock instance can safely be accessed from multiple processes, or not. The actual way of accessing this SharedMutex is unspecified, but typically this is coordinated via SharedMemory.

      The value returned is constant.

      Returns:
      true if inter-process access is permitted.