## org.exist.storage.lock
Interface Lock

All Known Implementing Classes:
  MultiReadReentrantLock, ReentrantReadWriteLock

public interface Lock

Field Summary
`static int` `NO_LOCK`
`static int` `READ_LOCK`
`static int` `WRITE_LOCK`

Method Summary
`boolean` `acquire()` Acquire a lock for read.
`boolean` `acquire(int mode)` Acquire a lock for read or write.
`boolean` `attempt(int mode)` Attempt to acquire a lock for read or write.
`boolean` `isLockedForWrite()` Returns true if there are active or pending write locks.
`void` `release()` Release a lock.
`void` `release(int mode)` Release a lock of the specified type.

Field Detail

### READ_LOCK

    public static final int READ_LOCK

See Also:
  Constant Field Values

### WRITE_LOCK

    public static final int WRITE_LOCK

See Also:
  Constant Field Values

### NO_LOCK

    public static final int NO_LOCK

See Also:
  Constant Field Values

Method Detail

### acquire

    public boolean acquire()
                    throws LockException

  Acquire a lock for read.

  Throws:
    `LockException`

### acquire

    public boolean acquire(int mode)
                    throws LockException

  Acquire a lock for read or write. mode is one of `READ_LOCK` or `WRITE_LOCK`.

  Parameters:
    `mode` -
  Throws:
    `LockException`

### attempt

    public boolean attempt(int mode)

  Attempt to acquire a lock for read or write. This method will fail immediately if the lock cannot be acquired.

  Parameters:
    `mode` -
  Throws:
    `LockException`

### release

    public void release()

  Release a lock. This method assumes that the lock is a read lock.

### release

    public void release(int mode)

  Release a lock of the specified type.

  Parameters:
    `mode` -

### isLockedForWrite

    public boolean isLockedForWrite()

  Returns true if there are active or pending write locks.

Copyright (C) Wolfgang Meier. All rights reserved.