org.jboss.mq.threadpool
Class ThreadPool

java.lang.Object
  extended byorg.jboss.mq.threadpool.ThreadPool

public class ThreadPool
extends java.lang.Object

This is an implementation of a simple thread pool with an embedded work queue.


Constructor Summary
ThreadPool(java.lang.String name, java.lang.ThreadGroup threadGroup, int maxWorkers, boolean daemon)
          Create a new thread pool instance.
 
Method Summary
 void cancelWork(Work (src)  work)
          Cancel a piece of enqueued work.
 void enqueueWork(Work (src)  work)
          Enqueue a piece of work for this thread to handle.
 void shutdown()
          Shutdown this thread pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadPool

public ThreadPool(java.lang.String name,
                  java.lang.ThreadGroup threadGroup,
                  int maxWorkers,
                  boolean daemon)
Create a new thread pool instance.

Parameters:
threadGroup - The ThreadGroup that worker threads in this pool should belong to.
maxWorkers - The maximum number of worker threads in this pool.
daemon - If true, worker threads will be created as daemon threads.
Method Detail

shutdown

public void shutdown()
Shutdown this thread pool. This will not return until all enqueued work has been cancelled, and all worker threads have done any work they started and have died.


enqueueWork

public void enqueueWork(Work (src)  work)
Enqueue a piece of work for this thread to handle. As soon as a thread becomes available, it will call Work.doWork() of the argument. If the pool is shutting down, this method will not enqueue the work, but instead simply return.

Parameters:
work - The piece of work to be enqueued.

cancelWork

public void cancelWork(Work (src)  work)
Cancel a piece of enqueued work.

Parameters:
work - The piece of work to be cancel.