|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
scranton.IteratorThread
An abstract class that implements the Iterator Interface by extending the Thread class allowing software developers to construct iterators over various containers by constructing an agorithm, as a run method, that visits each object int the container and calls the produce method to make the object available to the consumer employing the iterator.
| Field Summary | |
protected boolean |
finished
Set to true when the producer terminates. |
protected boolean |
full
Boolean mailbox flag used by the producer/consumer methods |
protected Guard |
iterating
The flag in the Guard object is set to false if the structure is changed while the iteration is in progress. |
protected java.lang.Object |
mailbox
The producer/consumer mailbox |
protected java.lang.Object |
removeback
Feedback to the extended class used by the remove() method. |
protected java.lang.Object |
removebox
The producer/consumer info to remove the object in the mailbox |
protected boolean |
terminate
Set to true when the consumer terminates the process. |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
protected |
IteratorThread(Guard fl)
|
| Method Summary | |
protected java.lang.Object |
consume()
Classical thread synchronization referenced by the next method to obtain the object. |
boolean |
hasNext()
Implements the Iterator's hasNext method |
java.lang.Object |
next()
Implements the Iterator's next method |
protected void |
produce(java.lang.Object obj,
java.lang.Object rem)
Classical thread code for a producer method that is called by the extended class's run method each time an object is produced. |
void |
remove()
Remove is not implemented within the thread. |
void |
terminate()
Referenced by the client when the client wishes to abort the iteration. |
protected void |
tookLast()
Called by the extended class's run method after all objects have been produced, it sets the "finished" flag after the last object has been consumed, or if the consumer terminated the iteration. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.lang.Object mailbox
protected java.lang.Object removebox
protected java.lang.Object removeback
protected boolean full
protected boolean finished
protected boolean terminate
protected Guard iterating
| Constructor Detail |
protected IteratorThread(Guard fl)
| Method Detail |
protected void produce(java.lang.Object obj,
java.lang.Object rem)
obj - The next object to be producedrem - Object that contains information for the remove methodprotected void tookLast()
public boolean hasNext()
hasNext in interface java.util.Iteratorpublic java.lang.Object next()
next in interface java.util.Iteratorprotected java.lang.Object consume()
public void remove()
remove in interface java.util.Iteratorpublic void terminate()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||