|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.metasyntactic.thread.AlternatingReadersWritersMonitor
The Alternating-Readers/Writers Monitor will give the shared structure to a waiting writer when readers have finished with it and to readers when a writer has finished with it.
| Field Summary | |
protected int |
nextBatch
Index in readersReadingAndWaiting of batch of number of readers waiting to read. |
protected int[] |
readersReadingAndWaiting
Number readers reading and waiting to read in this batch or the next batch. |
protected int |
thisBatch
Index in nr of batch of number of readers currently reading. |
protected int |
writersTotal
Number of writers total. |
protected int |
writerWriting
Number writers writing, 0 or 1 |
| Constructor Summary | |
AlternatingReadersWritersMonitor()
|
|
| Method Summary | |
void |
startReading()
Called to begin reading the shared data structure. |
void |
startWriting()
Called to begin writing the shared data structure. |
void |
stopReading()
Called when the thread is finished reading the shared data structure. |
void |
stopWriting()
Called when the thread is finished writing the shared data structure. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int thisBatch
protected int nextBatch
protected int[] readersReadingAndWaiting
protected int writerWriting
protected int writersTotal
| Constructor Detail |
public AlternatingReadersWritersMonitor()
| Method Detail |
public void startReading()
throws java.lang.InterruptedException
ReaderWriterMonitor
startReading in interface ReaderWriterMonitorjava.lang.InterruptedException - When the thread is interrupted before startingpublic void stopReading()
ReaderWriterMonitor
stopReading in interface ReaderWriterMonitor
public void startWriting()
throws java.lang.InterruptedException
ReaderWriterMonitor
startWriting in interface ReaderWriterMonitorjava.lang.InterruptedException - When the thread is interrupted before startingpublic void stopWriting()
ReaderWriterMonitor
stopWriting in interface ReaderWriterMonitor
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||