|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.metasyntactic.thread.TakeANumberMonitor
As each reader or writer arrives, it takes the next number and threads are served in order by their number. However, all readers with consecutive numbers are served at the same time.
| Field Summary | |
protected int |
nextNumber
Take a number |
protected int |
nowServing
Number now being served |
protected int |
readersReading
Number readers reading |
| Constructor Summary | |
TakeANumberMonitor()
|
|
| 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 nextNumber
protected int nowServing
| Constructor Detail |
public TakeANumberMonitor()
| 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 | |||||||||