|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jini.thread.ReadersWriter
public class ReadersWriter
An Object to control the concurrent state. Allows multiple readers or a single writer. Waiting writers have priority over new readers. Waiting priority writers have priority over waiting regular writers. A single thread cannot hold a lock more than once.
Nested Class Summary | |
---|---|
static class |
ReadersWriter.ConcurrentLockException
InterruptedException transformed to a runtime exception. |
Field Summary | |
---|---|
private int |
activeReaders
The number of active readers |
private boolean |
activeWriter
True if there is an active writer |
private int |
waitingPriorityWriters
The number of waiting priority writers |
private int |
waitingWriters
The number of waiting writers (both regular and priority) |
Constructor Summary | |
---|---|
ReadersWriter()
|
Method Summary | |
---|---|
void |
priorityWriteLock()
Obtain a priority write lock. |
void |
readerWait(Object notifier,
long time)
Release a read lock, wait the given period of time or until notified by notifier, then obtain a read lock again. |
void |
readLock()
Obtain a read lock. |
void |
readUnlock()
Release a read lock. |
void |
waiterNotify(Object notifier)
Wake up any threads waiting on this notifier. |
void |
writeLock()
Obtain a regular write lock. |
void |
writerWait(Object notifier,
long time)
Release a write lock, wait the given period of time or until notified by notifier, then obtain a regular write lock again. |
void |
writeUnlock()
Release a (regular or priority) write lock. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int activeReaders
private int waitingWriters
private int waitingPriorityWriters
private boolean activeWriter
Constructor Detail |
---|
public ReadersWriter()
Method Detail |
---|
public void readLock()
public void readUnlock()
public void writeLock()
public void priorityWriteLock()
public void writeUnlock()
public void readerWait(Object notifier, long time)
public void writerWait(Object notifier, long time)
public void waiterNotify(Object notifier)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |