Class ThreadPool

All Implemented Interfaces:

public class ThreadPool
extends java.lang.Object

The class ThreadPool implements a thread pool. A thread pool is used to prevent the server from creating to many threads, which will hit the performance. Instead a constant number of threads is created. When a task is to be executed asynchronous, a thread is requested and the task is executed. If there is currently no thread available, the task is delayed until a thread becomes available.


 $Log:,v $
 Revision 1.5  2001/06/27 19:09:18  jiriki
 Resolved minor bugs. Updated docs.

 Revision 1.4  2001/06/12 17:14:33  jiriki
 - Reimplemented DistributedList to make filters working
 - Made ServertestCase working.

 Revision 1.3  2001/05/22 20:24:40  jiriki
 Made source more conformant to Coding Conventions.,v
 Revision 1.12  2001/04/09 15:36:19  wombat
 Improved UserImpl, removed bugs

 Revision 1.11  2001/04/09 13:03:10  wombat
 Removed timeout from threadpool (did not work)

 Revision 1.10  2001/03/21 13:26:36  wombat
 - Removed bugs in Table
 - began implementation of stree client
 - updated documentation

 Revision 1.9  2001/03/20 16:01:59  wombat
 Introduced persistant tasks

 Revision 1.8  2001/03/18 17:32:04  wombat
 Changed database concept

 Revision 1.7  2001/02/25 23:16:05  wombat
 - deadlock vermeidung umgestellt.
 - ListenerList erstellt

 Revision 1.6  2001/02/06 14:29:09  wombat
 Updated documentation

 Revision 1.5  2001/02/06 11:32:50  wombat
 started ssl implementation

 Revision 1.4  2001/02/04 17:12:59  wombat
 - updated Documentation
 - continued implementation of UserManger

 Revision 1.3  2001/01/31 11:28:12  wombat
 Updated Documentation.


$Revision: 1.5 $ ($Date: 2001/06/27 19:09:18 $)
Jan-Ole Janssen, Timo Sticher, Niklas Mehner
See Also:
Serialized Form

Method Summary
 void close()
          Close the ThreadPool.
 WaitObject executeAsync(java.util.List tasks)
          Executes a list of tasks asynchronous.
 WaitObject executeAsync(java.lang.Runnable task)
          Executes a task asynchronous.
 void executeFutureTask(long time, java.lang.Runnable task)
          Executes a task in the future.
static ThreadPool getThreadPool()
          Returns the singleton instance of the ThreadPool.
 int getThreadPoolThreads()
          Return the number of threads in the thread pool
 void setThreadPoolThreads(int threads)
          Set the number of threads in the thread pool.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail


public WaitObject executeAsync(java.util.List tasks)
Executes a list of tasks asynchronous. All entries in the task list have to implement the Runnable interface. When all tasks are finished, the WaitObjects wait method returns.
tasks - list of tasks to be executed.
A WaitObject. The waitForCalls method of the WaitObject returns, when all tasks have ended.


public WaitObject executeAsync(java.lang.Runnable task)
Executes a task asynchronous.
task - task to be executed.
A WaitObject, that can be used to determine, if the task is finished.


public void executeFutureTask(long time,
                              java.lang.Runnable task)
Executes a task in the future. For persistant tasks (tasks that implement the interface) it is ensured, that the task is executed, even if the server performs an unexpected shutdown. If the shutdown occurs, while an persistant task is executed, it is started again, when the server is started again. This means, that a persistant may (in rare circumstances) be executed two times.
time - time (in millis) until the task should be started.
task - task to be executed.


public static ThreadPool getThreadPool()
Returns the singleton instance of the ThreadPool.
The ThreadPool.


public int getThreadPoolThreads()
Return the number of threads in the thread pool
Number of threads.


public void setThreadPoolThreads(int threads)
Set the number of threads in the thread pool.
threads - Number of threads.


public void close()
Close the ThreadPool. All Threads are stopped.