org.ws4d.java.concurrency
Interface Lockable

All Known Subinterfaces:
LocalDevice
All Known Implementing Classes:
DefaultDevice, LockedList, LockedMap, LockedStructure, LockSupport

public interface Lockable


Method Summary
 void exclusiveLock()
          Acquires an exclusive lock.
 boolean releaseExclusiveLock()
          Releases an exclusive lock of the current thread.
 void releaseSharedLock()
          Releases a shared lock of the current thread.
 void sharedLock()
          Acquires a shared lock.
 boolean tryExclusiveLock()
          Try to get an exclusive lock immediately.
 boolean trySharedLock()
          Tries to get a shared lock immediately.
 

Method Detail

sharedLock

void sharedLock()
Acquires a shared lock. If the lock cannot be allocated immediately, the thread is blocked until allocation is possible.


exclusiveLock

void exclusiveLock()
Acquires an exclusive lock. If the lock cannot be allocated immediately, the thread is blocked until allocation is possible.


trySharedLock

boolean trySharedLock()
Tries to get a shared lock immediately.

Returns:
true if the lock has been allocated, false otherwise

tryExclusiveLock

boolean tryExclusiveLock()
Try to get an exclusive lock immediately.

Returns:
true if the lock has been allocated, false otherwise

releaseSharedLock

void releaseSharedLock()
Releases a shared lock of the current thread.


releaseExclusiveLock

boolean releaseExclusiveLock()
Releases an exclusive lock of the current thread.

Returns:
true = if last exclusive lock of this thread is released.