org.jgroups.util

Class 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

Nested 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

Constructor Details

RWLock

public RWLock()

Method Details

readLock

public void readLock()
Obtain a 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

readUnlock

public void readUnlock()
Revoke the read lock

writeLock

public void writeLock()
Obtain a 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

writeUnlock

public void writeUnlock()
Revoke the write lock

Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.