fipaos.util
Class ThreadPool


public class ThreadPool
implements 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
 public static classThreadPool.Job
          Interface to be implemented by objects to be executed by threads within a ThreadPool
 public classThreadPool.TPThread
          Extends Thread to provide the ThreadGroup of the thread that requested the Job be carried out

Constructor Summary
ThreadPool(int number_of_threads, 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
 synchronized voidaddJob(Job job)
          Add a Job to be executed by the ThreadPool
 synchronized intgetActiveThreadCount()
          Get the number of active threads
 static synchronized ThreadPoolgetGlobalThreadPool()
          Get the global thread-pool
 StringgetName()
          Get the name of the thread pool
 intgetThreadCount()
          Get the number of threads
 static SetgetThreadPools()
          Get a set of all thread-pools
 synchronized longgetTotalActiveTime()
          Get the number of active threads
 synchronized longgetTotalInactiveTime()
          Get the number of threads
 intgetWaitingJobCount()
          Get the number of waiting Jobs
 static voidmain(String[] args)
          Test harness
 voidrun()
          Invoked by each thread in the ThreadPool
 synchronized voidshutdown()
          Terminate all threads & stop executing pending jobs - doesn't block
 StringtoString()
          Returns name of ThreadPool

Constructor Detail

ThreadPool

public ThreadPool(int number_of_threads, 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

addJob

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

getActiveThreadCount

public synchronized int getActiveThreadCount()
Get the number of active threads

getGlobalThreadPool

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

getName

public String getName()
Get the name of the thread pool

getThreadCount

public int getThreadCount()
Get the number of threads

getThreadPools

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

getTotalActiveTime

public synchronized long getTotalActiveTime()
Get the number of active threads

getTotalInactiveTime

public synchronized long getTotalInactiveTime()
Get the number of threads

getWaitingJobCount

public int getWaitingJobCount()
Get the number of waiting Jobs

main

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

run

public void run()
Invoked by each thread in the ThreadPool

shutdown

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

toString

public String toString()
Returns name of ThreadPool

Association Links

to Class fipaos.util.ThreadPool

Global thread-pool

to Class java.util.Set

Set of all ThreadPool objects

to Class java.util.List

List of Threads in this ThreadPool

to Class fipaos.util.Queue

Queue containing jobs to be executed

to Class java.lang.String

Name of this thread pool