net.sourceforge.cruisecontrol.util.threadpool
Class ThreadQueue

java.lang.Object
  extended byjava.lang.Thread
      extended bynet.sourceforge.cruisecontrol.util.threadpool.ThreadQueue
All Implemented Interfaces:
java.lang.Runnable

public class ThreadQueue
extends java.lang.Thread

Used to encapsulate the concept of a Thread Pool

The queue accepts tasks that implement the WorkerThread interface. Each task may be named, but do not have to be. You may then waitOn for ever task to complete or just the named tasks you care about... or not wait at all.

Version:
$Id: ThreadQueue.java 2800 2007-01-28 08:52:59Z jfredrick $
Author:
Jared Richardson

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ThreadQueue()
           
 
Method Summary
static void addTask(WorkerThread task)
          Adds a task to the idleList to be executed
static java.lang.String findPosition(java.lang.String taskName)
          This may not *always* work -- a task may slip by us between queue checks.
static java.util.List getBusyTaskNames()
           
static java.util.List getIdleTaskNames()
           
static boolean isActive(java.lang.String taskName)
          Checks to see if a specific task is either running or waiting in our system
 void run()
           
 
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, 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
 

Constructor Detail

ThreadQueue

public ThreadQueue()
Method Detail

run

public void run()

addTask

public static void addTask(WorkerThread task)
Adds a task to the idleList to be executed


findPosition

public static java.lang.String findPosition(java.lang.String taskName)
This may not *always* work -- a task may slip by us between queue checks. That's OK. We'd rather have transient results than block the busy queue until we're done just to get a position report on a task.


isActive

public static boolean isActive(java.lang.String taskName)
Checks to see if a specific task is either running or waiting in our system

Returns:
TRUE if task is waiting or running, FALSE if it is finished

getBusyTaskNames

public static java.util.List getBusyTaskNames()
Returns:
the names of the tasks in the busy list; may be empty

getIdleTaskNames

public static java.util.List getIdleTaskNames()
Returns:
the names of the tasks in the idle list; may be empty