fipaos.util
Class ThreadPool

java.lang.Object
  |
  +--fipaos.util.ThreadPool
All Implemented Interfaces:
java.lang.Runnable

public class ThreadPool
extends java.lang.Object
implements java.lang.Runnable

Implements a pool of Threads - enables multiple threads to be used within an apllication without the associated overhead of starting new Threads, since Threads are re-used


Inner Class Summary
static interface ThreadPool.Job
          Interface to be implemented by objects to be executed by threads within a ThreadPool
 class ThreadPool.TPThread
          Extends Thread to provide the ThreadGroup of the thread that requested the Job be carried out
 
Constructor Summary
ThreadPool(int number_of_threads, java.lang.String name)
          Create a thread pool with the specified number of threads, and a name to use as a prefix for the thread names
 
Method Summary
 void addJob(ThreadPool.Job job)
          Add a Job to be executed by the ThreadPool
 int getActiveThreadCount()
          Get the number of active threads
static ThreadPool getGlobalThreadPool()
          Get the global thread-pool
 java.lang.String getName()
          Get the name of the thread pool
 int getThreadCount()
          Get the number of threads
static java.util.Set getThreadPools()
          Get a set of all thread-pools
 long getTotalActiveTime()
          Get the number of active threads
 long getTotalInactiveTime()
          Get the number of threads
 int getWaitingJobCount()
          Get the number of waiting Jobs
static void main(java.lang.String[] args)
          Test harness
 void run()
          Invoked by each thread in the ThreadPool
 void shutdown()
          Terminate all threads & stop executing pending jobs - doesn't block
 java.lang.String toString()
          Returns name of ThreadPool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadPool

public ThreadPool(int number_of_threads,
                  java.lang.String name)
Create a thread pool with the specified number of threads, and a name to use as a prefix for the thread names
Method Detail

run

public void run()
Invoked by each thread in the ThreadPool
Specified by:
run in interface java.lang.Runnable

addJob

public void addJob(ThreadPool.Job job)
Add a Job to be executed by the ThreadPool

shutdown

public void shutdown()
Terminate all threads & stop executing pending jobs - doesn't block

getName

public java.lang.String getName()
Get the name of the thread pool

getActiveThreadCount

public int getActiveThreadCount()
Get the number of active threads

getThreadCount

public int getThreadCount()
Get the number of threads

getTotalActiveTime

public long getTotalActiveTime()
Get the number of active threads

getTotalInactiveTime

public long getTotalInactiveTime()
Get the number of threads

getWaitingJobCount

public int getWaitingJobCount()
Get the number of waiting Jobs

toString

public java.lang.String toString()
Returns name of ThreadPool
Overrides:
toString in class java.lang.Object

getGlobalThreadPool

public static ThreadPool getGlobalThreadPool()
Get the global thread-pool

getThreadPools

public static java.util.Set getThreadPools()
Get a set of all thread-pools

main

public static void main(java.lang.String[] args)
Test harness