org.javagroups.util
Class RWLock

java.lang.Object
  |
  +--org.javagroups.util.RWLock

public class RWLock
extends java.lang.Object

Lock allowing multiple reads or a single write. Waiting writes have priority over new reads.

Code derived from com.sun.jini.thread.ReadersWriter, Jini 1.1, Sun Microsystems


Inner Class Summary
static class RWLock.BlockException
          Exception thrown when a lock request would block the caller
static class RWLock.IntException
          Interrupted exception wrapped in a RuntimeException
 
Constructor Summary
RWLock()
           
 
Method Summary
 void readLock()
          Obtain a read lock
 void readLockNoBlock()
          Obtain the read lock immediatelly or throw an exception if an attempt to get the read lock would block this call
 void readUnlock()
          Revoke the read lock
 void writeLock()
          Obtain a write lock
 void writeLockNoBlock()
          Obtain the write lock immediatelly or throw an exception if an attempt to get the write lock would block this call
 void writeUnlock()
          Revoke the write lock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RWLock

public RWLock()
Method Detail

readLock

public void readLock()
Obtain a read lock
Throws:
RWLock.IntException - if interrupted while waiting on the lock

readUnlock

public void readUnlock()
Revoke the read lock

readLockNoBlock

public void readLockNoBlock()
                     throws RWLock.BlockException
Obtain the read lock immediatelly or throw an exception if an attempt to get the read lock would block this call
Throws:
RWLock.BlockException - if attempt to get the read lock would block this call

writeLock

public void writeLock()
Obtain a write lock
Throws:
RWLock.IntException - if interrupted while waiting on the lock

writeUnlock

public void writeUnlock()
Revoke the write lock

writeLockNoBlock

public void writeLockNoBlock()
                      throws RWLock.BlockException
Obtain the write lock immediatelly or throw an exception if an attempt to get the write lock would block this call
Throws:
RWLock.BlockException - if attempt to get the write lock would block this call


Copyright © 2001,2002 www.javagroups.com . All Rights Reserved.