Package org.apache.axis2.util.threadpool
Class ThreadPool
- java.lang.Object
-
- org.apache.axis2.util.threadpool.ThreadPool
-
- All Implemented Interfaces:
ThreadFactory
public class ThreadPool extends Object implements ThreadFactory
This the thread pool for axis2. This class will be used a singleton across axis2 engine.ThreadPool
is acceptsAxisWorkers
which has run method on them and execute this method, using one of the threads in the thread pool.
-
-
Field Summary
Fields Modifier and Type Field Description protected ThreadPoolExecutor
executor
protected static long
SLEEP_INTERVAL
-
Constructor Summary
Constructors Constructor Description ThreadPool()
ThreadPool(int corePoolSize, int maxPoolSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ThreadPoolExecutor
createDefaultExecutor(String name, int priority, boolean daemon)
void
execute(Runnable worker)
void
forceShutDown()
A forceful shutdown mechanism for thread pool.Executor
getExecutor()
void
safeShutDown()
This is the recommended shutdown method for the thread pool This will wait till all the workers that are already handed over to the thread pool get executed.void
setExecutor(ThreadPoolExecutor executor)
-
-
-
Field Detail
-
SLEEP_INTERVAL
protected static long SLEEP_INTERVAL
-
executor
protected ThreadPoolExecutor executor
-
-
Method Detail
-
getExecutor
public Executor getExecutor()
-
setExecutor
public void setExecutor(ThreadPoolExecutor executor)
-
execute
public void execute(Runnable worker)
- Specified by:
execute
in interfaceThreadFactory
-
forceShutDown
public void forceShutDown()
A forceful shutdown mechanism for thread pool.
-
safeShutDown
public void safeShutDown() throws AxisFault
This is the recommended shutdown method for the thread pool This will wait till all the workers that are already handed over to the thread pool get executed.- Throws:
AxisFault
-
createDefaultExecutor
protected ThreadPoolExecutor createDefaultExecutor(String name, int priority, boolean daemon)
-
-