org.jacorb.imr

Class ResourceLock

public class ResourceLock extends Object implements 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: ResourceLock.java,v 1.3 2004/05/06 12:39:59 nicolas Exp $

Constructor Summary
ResourceLock()
The constructor.
Method Summary
voidgainExclusiveLock()
This method tries to aquire an exclusive lock.
voidgainSharedLock()
This method tries to aquire a shared lock.
voidreleaseExclusiveLock()
Releases the exclusive lock.
voidreleaseSharedLock()
Release the shared lock.

Constructor Detail

ResourceLock

public ResourceLock()
The constructor.

Method Detail

gainExclusiveLock

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

gainSharedLock

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

releaseExclusiveLock

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

releaseSharedLock

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