|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.metasyntactic.thread.ReadersPreferredMonitor
Implementation of MultipleReadersWritersMonitor that gives preference to readers. A reader may not begin reading if there is a writer writing; otherwise, it may begin immediately. A writer may not begin writing if there are any readers present or if another writer is writing.
Field Summary | |
protected int |
readersReading
number readers reading |
protected int |
readersTotal
number of readers total (reading or waiting to read) |
protected int |
writersTotal
number of writers total (writing or waiting to write) |
protected int |
writerWriting
number writers writing, 0 or 1 |
Constructor Summary | |
ReadersPreferredMonitor()
|
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 readersReading
protected int readersTotal
protected int writerWriting
protected int writersTotal
Constructor Detail |
public ReadersPreferredMonitor()
Method Detail |
public void startReading() throws java.lang.InterruptedException
ReaderWriterMonitor
startReading
in interface ReaderWriterMonitor
java.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 ReaderWriterMonitor
java.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 |