com.agentfactory.cldc.scheduler
Class WorkerThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.agentfactory.cldc.scheduler.WorkerThread
All Implemented Interfaces:
java.lang.Runnable

public class WorkerThread
extends java.lang.Thread

The worker threads extract tasks from the task buffer and execute them.

Author:
Conor Muldoon

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
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WorkerThread(Buffer buffer, java.util.Vector activeSet)
          Creates a new instance of WorkerThread.
 
Method Summary
 void destroy()
          Kills the thread (Provided the buffer has been interrupted).
 void run()
          While the thread is alive, removes tasks from the tast buffer, executes them, and then removes them from the active set.
 void toggle()
          Toggles the worker thread from active to inactive and vice versa.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WorkerThread

public WorkerThread(Buffer buffer,
                    java.util.Vector activeSet)
Creates a new instance of WorkerThread.

Parameters:
buffer - the buffer to extract tasks from.
activeSet - the set of active tasks.
Method Detail

run

public void run()
While the thread is alive, removes tasks from the tast buffer, executes them, and then removes them from the active set.

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

toggle

public void toggle()
Toggles the worker thread from active to inactive and vice versa.


destroy

public void destroy()
Kills the thread (Provided the buffer has been interrupted).

Overrides:
destroy in class java.lang.Thread