dsto.dfc.util
Class MultiplexedThread

java.lang.Object
  extended by java.lang.Thread
      extended by dsto.dfc.util.MultiplexedThread
All Implemented Interfaces:
Runnable

public class MultiplexedThread
extends Thread

Allows a thread to be multiplexed into several scheduled Runnable's. This is essentially Matthew's simple version of java.util.Timer that (a) allows tasks to re-schedule themselves inside their run () method (why did Sun actively block that?) and (b) allows managed shutdown-and-join (no way to tell when a cancelled Timer has finished running tasks).

Author:
Matthew Phillips

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MultiplexedThread()
           
 
Method Summary
 void run()
           
 void schedule(Runnable runnable, long time)
          Schedule a runnable for execution.
 void shutdown()
          Requests shutdown of the thread.
 
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

MultiplexedThread

public MultiplexedThread()
Method Detail

shutdown

public void shutdown()
Requests shutdown of the thread. If a runnable is executing it is completed.


schedule

public void schedule(Runnable runnable,
                     long time)
Schedule a runnable for execution.

Parameters:
runnable - The runnable.
time - The time to run at.

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread


Copyright © 2008 Commonwealth of Australia