Class ThreadQueue

  extended by java.lang.Thread
      extended by
All Implemented Interfaces:

public class ThreadQueue
extends java.lang.Thread

The ThreadQueue class provides a mechanism to run threads serially. When a thread is added, it will be started as soon as all threads added before it have completed. From the book: Essential JMF, Gordon, Talley (ISBN 0130801046). Used with permission.

Steve Talley & Rob Gordon

Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
Field Summary
Fields inherited from class java.lang.Thread
Constructor Summary
ThreadQueue(java.lang.String threadName)
          Constructs a ThreadQueue.
Method Summary
 void addThread(java.lang.Thread t)
          Add a thread to this ThreadQueue.
 void run()
          Monitor the thread queue.
 void stopThreads()
          Stop the currently running thread and any threads queued to run.
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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

Constructor Detail


public ThreadQueue(java.lang.String threadName)
Constructs a ThreadQueue.

Method Detail


public void run()
Monitor the thread queue. When a thread is added, start it and block until it finishes.

This method is called when the thread is started. It should not be called directly.

Specified by:
run in interface java.lang.Runnable
run in class java.lang.Thread


public void addThread(java.lang.Thread t)
Add a thread to this ThreadQueue.

t - The Thread to add.


public void stopThreads()
Stop the currently running thread and any threads queued to run. Remove all threads from the queue.