net.livesite.util
Class ThreadPool

java.lang.Object
  extended by java.lang.ThreadGroup
      extended by net.livesite.util.ThreadPool
All Implemented Interfaces:
Thread.UncaughtExceptionHandler

public class ThreadPool
extends ThreadGroup

Create, run, and track threads.


Nested Class Summary
 class ThreadPool.RunThread
          Extends thread with members to track state such as start time.
 
Constructor Summary
ThreadPool(String name)
          Constructs this class
ThreadPool(ThreadGroup parent, String name)
          Constructs this class
 
Method Summary
 ThreadPool.RunThread create(Runnable target, String name)
          Creates a new child thread with the provided Runnable object.
 ThreadPool.RunThread getThread(String name)
          Get a thread in our group.
 Vector getThreadsByType(String name)
          Get a threads which contain the provided name.
 ThreadPool.RunThread spawn(Runnable target, String name)
          Creates and runs a new child thread with the provided Runnable object.
 
Methods inherited from class java.lang.ThreadGroup
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString, uncaughtException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadPool

public ThreadPool(String name)
Constructs this class

Parameters:
name - String the name of the new thread group

ThreadPool

public ThreadPool(ThreadGroup parent,
                  String name)
Constructs this class

Parameters:
parent - ThreadGroup the parent thread group
name - String the name of the new thread group
Method Detail

spawn

public ThreadPool.RunThread spawn(Runnable target,
                                  String name)
Creates and runs a new child thread with the provided Runnable object.

Parameters:
target - Runnable the runnable object to be started
name - String the name of the new thread
Returns:
Thread the created thread

create

public ThreadPool.RunThread create(Runnable target,
                                   String name)
Creates a new child thread with the provided Runnable object.

Parameters:
target - Runnable the runnable object to be started
name - String the name of the new thread
Returns:
Thread the created thread

getThread

public ThreadPool.RunThread getThread(String name)
Get a thread in our group.

Parameters:
name - String Name of the thread to return.
Returns:
RunThread or null if the thread is not found.

getThreadsByType

public Vector getThreadsByType(String name)
Get a threads which contain the provided name.

Parameters:
name - String match thread names containing this.
Returns:
Vector or null if no threads are found.