org.jacorb.imr
Class RessourceLock

java.lang.Object
  extended byorg.jacorb.imr.RessourceLock
All Implemented Interfaces:
java.io.Serializable

public class RessourceLock
extends java.lang.Object
implements java.io.Serializable

This class provides shared or exclusive access to a ressource. It preferes the exclusive access, i.e. if threads are waiting for exclusive access, shared locks can't be gained.

Author:
Nicolas Noffke $Id: RessourceLock.java,v 1.7 2003/12/16 08:41:27 gerald Exp $
See Also:
Serialized Form

Constructor Summary
RessourceLock()
          The constructor.
 
Method Summary
 void gainExclusiveLock()
          This method tries to aquire an exclusive lock.
 void gainSharedLock()
          This method tries to aquire a shared lock.
 void releaseExclusiveLock()
          Releases the exclusive lock.
 void releaseSharedLock()
          Release the shared lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RessourceLock

public RessourceLock()
The constructor.

Method Detail

gainSharedLock

public void gainSharedLock()
This method tries to aquire a shared lock. It blocks until the exclusive lock is released.


releaseSharedLock

public void releaseSharedLock()
Release the shared lock. Unblocks threads waiting for access.


gainExclusiveLock

public void gainExclusiveLock()
This method tries to aquire an exclusive lock. It blocks until all shared locks have been released.


releaseExclusiveLock

public void releaseExclusiveLock()
Releases the exclusive lock. Unblocks all threads waiting for access.