scone.util
Class ThreadPool

java.lang.Object
  extended by scone.util.ThreadPool

public class ThreadPool
extends java.lang.Object

an unlimited pool of Threads. This pool may be used for Thread-recycling in order to avoid expensive creating and destroying of Threads. In order to execute code in a PoolThread, call the ThreadPool's execute() method.


Constructor Summary
ThreadPool()
           
 
Method Summary
 void close()
          closes the pool and terminates all idle Threads.
 void execute(java.lang.Runnable runnable)
          executes the specified Runnable in a Thread.
 boolean isClosed()
          returns true, when the pool has been closed.
 void reportIdle(scone.util.PoolThread pt)
          reports a Thread to be idle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadPool

public ThreadPool()
Method Detail

execute

public void execute(java.lang.Runnable runnable)
executes the specified Runnable in a Thread. If available, an idle Thread will be reused. If not, a new one will be created. Does nothing if the pool is closed.

Parameters:
runnable - the code to be executed in a Thread

close

public void close()
closes the pool and terminates all idle Threads. Busy threads will terminate after their Runnable has terminated.


isClosed

public boolean isClosed()
returns true, when the pool has been closed.

Returns:
true if the pool has been closed.

reportIdle

public void reportIdle(scone.util.PoolThread pt)
reports a Thread to be idle. This should rather be an internal method.

Parameters:
pt - the PoolThread