org.ws4d.java.concurrency
Class LockSupport

java.lang.Object
  extended by org.ws4d.java.concurrency.LockSupport
All Implemented Interfaces:
Lockable

public class LockSupport
extends java.lang.Object
implements Lockable

Implementation of a multiple-readers/single-writer lock support.


Constructor Summary
LockSupport()
          Constructs a new LockSupport.
 
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.
 java.lang.String toString()
           
 boolean tryExclusiveLock()
          Try to get an exclusive lock immediately.
 boolean trySharedLock()
          Tries to get a shared lock immediately.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LockSupport

public LockSupport()
Constructs a new LockSupport.

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

sharedLock

public void sharedLock()
Description copied from interface: Lockable
Acquires a shared lock. If the lock cannot be allocated immediately, the thread is blocked until allocation is possible.

Specified by:
sharedLock in interface Lockable

exclusiveLock

public void exclusiveLock()
Description copied from interface: Lockable
Acquires an exclusive lock. If the lock cannot be allocated immediately, the thread is blocked until allocation is possible.

Specified by:
exclusiveLock in interface Lockable

trySharedLock

public boolean trySharedLock()
Description copied from interface: Lockable
Tries to get a shared lock immediately.

Specified by:
trySharedLock in interface Lockable
Returns:
true if the lock has been allocated, false otherwise

tryExclusiveLock

public boolean tryExclusiveLock()
Description copied from interface: Lockable
Try to get an exclusive lock immediately.

Specified by:
tryExclusiveLock in interface Lockable
Returns:
true if the lock has been allocated, false otherwise

releaseSharedLock

public void releaseSharedLock()
Description copied from interface: Lockable
Releases a shared lock of the current thread.

Specified by:
releaseSharedLock in interface Lockable

releaseExclusiveLock

public boolean releaseExclusiveLock()
Description copied from interface: Lockable
Releases an exclusive lock of the current thread.

Specified by:
releaseExclusiveLock in interface Lockable
Returns:
true = if last exclusive lock of this thread is released.