net.sf.asterisk.util
Class ThreadPool

java.lang.Object
  extended by net.sf.asterisk.util.ThreadPool

public class ThreadPool
extends java.lang.Object

A fixed sized thread pool.

Version:
$Id: ThreadPool.java,v 1.6 2005/10/25 23:10:33 srt Exp $
Author:
srt

Constructor Summary
ThreadPool(java.lang.String name, int numThreads)
          Creates a new ThreadPool of numThreads size.
 
Method Summary
 void addJob(java.lang.Runnable runnable)
          Adds a new job to the queue.
 void shutdown()
          Turn off the 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,
                  int numThreads)
Creates a new ThreadPool of numThreads size. These Threads are waiting for jobs to be added via the addJob method.

Parameters:
name - the name to use for the thread group and worker threads.
numThreads - the number of threads to create.
Method Detail

addJob

public void addJob(java.lang.Runnable runnable)
Adds a new job to the queue. This will be picked up by the next available active thread.


shutdown

public void shutdown()
Turn off the pool. Every thread, when finished with its current work, will realize that the pool is no longer running, and will exit.



Copyright © 2004-2005 Stefan Reuter. All Rights Reserved.