public class ThreadPool extends java.lang.Object implements IThreadPool
| Modifier and Type | Class and Description | 
|---|---|
| class  | ThreadPool.ServiceThreadA service thread executes tasks. | 
| Modifier and Type | Field and Description | 
|---|---|
| protected static java.util.Map<java.lang.Class<?>,java.lang.Integer> | callsService calls per runnable class. | 
| protected boolean | daemonThe daemon flag. | 
| protected java.util.Map<java.lang.Runnable,java.lang.Long> | enqueuetimesThe current throughput of the pool (average of waiting times). | 
| protected boolean | finishedBoolean if already finished. | 
| protected java.lang.ThreadGroup | groupThe thread group. | 
| protected java.util.List<IChangeListener<java.lang.Void>> | listenersThe finished listeners. | 
| protected int | maxparkedThe maximum number of parked threads. | 
| protected long | maxwaitThe time a task should maximum wait. | 
| protected java.util.List<ThreadPool.ServiceThread> | parkedThe list of threads not used. | 
| protected java.util.List<ThreadPool.ServiceThread> | poolThe pool of service threads. | 
| protected static int | poolcntThe static thread pool number. | 
| static long | PRINT_DELAYPrint every 10 seconds. | 
| static boolean | PROFILINGEnable call profiling. | 
| protected boolean | runningThe running flag. | 
| protected IPoolStrategy | strategyThe strategy. | 
| protected IBlockingQueue<java.lang.Runnable> | tasksThe tasks to execute. | 
| protected static int | threadcntThe thread number. | 
| protected java.util.Timer | timerRescue timer that checks if progress is made and tasks are scheduled. | 
| static java.util.Map<java.lang.Thread,Future<?>> | WAITING_THREADSThreads waiting due to thread suspendable. | 
| Constructor and Description | 
|---|
| ThreadPool()Create a new thread pool. | 
| ThreadPool(boolean daemon,
          IPoolStrategy strategy)Create a new thread pool. | 
| ThreadPool(boolean daemon,
          IPoolStrategy strategy,
          long maxwait)Create a new thread pool. | 
| ThreadPool(IPoolStrategy strategy)Create a new thread pool. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addFinishListener(IChangeListener<java.lang.Void> listener)Add a finish listener; | 
| protected void | addThread() | 
| protected void | addThreads(int num)Create some pool. | 
| void | dispose()Shutdown the task pool | 
| void | execute(java.lang.Runnable task)Execute a task in its own thread. | 
| protected java.lang.Runnable | getTask(java.lang.Thread thread)The task for a given thread. | 
| boolean | isRunning()Test if the thread pool is running. | 
| static void | main(java.lang.String[] args)Main for testing. | 
| protected void | notifyFinishListeners()Notify the finish listeners. | 
| java.lang.String | toString()Get the string representation. | 
public static final java.util.Map<java.lang.Thread,Future<?>> WAITING_THREADS
public static final boolean PROFILING
public static final long PRINT_DELAY
protected static java.util.Map<java.lang.Class<?>,java.lang.Integer> calls
protected static int threadcnt
protected static int poolcnt
protected java.lang.ThreadGroup group
protected IPoolStrategy strategy
protected java.util.List<ThreadPool.ServiceThread> pool
protected java.util.List<ThreadPool.ServiceThread> parked
protected IBlockingQueue<java.lang.Runnable> tasks
protected volatile boolean running
protected boolean daemon
protected java.util.Map<java.lang.Runnable,java.lang.Long> enqueuetimes
protected int maxparked
protected java.util.Timer timer
protected long maxwait
protected java.util.List<IChangeListener<java.lang.Void>> listeners
protected boolean finished
public ThreadPool()
public ThreadPool(IPoolStrategy strategy)
public ThreadPool(boolean daemon,
                  IPoolStrategy strategy)
public ThreadPool(boolean daemon,
                  IPoolStrategy strategy,
                  long maxwait)
public boolean isRunning()
isRunning in interface IThreadPoolpublic void execute(java.lang.Runnable task)
execute in interface IThreadPooltask - The task to execute.public void dispose()
dispose in interface IThreadPoolpublic java.lang.String toString()
toString in class java.lang.Objectprotected void addThreads(int num)
num - The number of pool.protected void addThread()
protected java.lang.Runnable getTask(java.lang.Thread thread)
public void addFinishListener(IChangeListener<java.lang.Void> listener)
addFinishListener in interface IThreadPoolprotected void notifyFinishListeners()
public static void main(java.lang.String[] args)
args - The arguments.