Class ThreadPool
java.lang.Object
org.apache.xmlrpc.util.ThreadPool
Simple thread pool. A task is executed by obtaining a thread from
the pool
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA task, which may be interrupted, if the pool is shutting down.private classstatic interfaceThe thread pool contains instances ofThreadPool.Task. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate intprivate final Listprivate final ThreadGroupprivate final Listprivate final List -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddTask(ThreadPool.Task pTask) Deprecated.No longer in use.intReturns the maximum number of concurrent threads.intReturns the number of threads, which have actually been created, as opposed to the number of currently running threads.private ThreadPool.PoolablegetPoolable(ThreadPool.Task pTask, boolean pQueue) private voidremove(ThreadPool.Poolable pPoolable) (package private) voidrepool(ThreadPool.Poolable pPoolable) voidshutdown()Closes the pool.booleanstartTask(ThreadPool.Task pTask) Starts a task immediately.
-
Field Details
-
threadGroup
-
maxSize
private final int maxSize -
waitingThreads
-
runningThreads
-
waitingTasks
-
num
private int num
-
-
Constructor Details
-
ThreadPool
Creates a new instance.- Parameters:
pMaxSize- Maximum number of concurrent threads.pName- Thread group name.
-
-
Method Details
-
remove
-
repool
-
startTask
Starts a task immediately.- Parameters:
pTask- The task being started.- Returns:
- True, if the task could be started immediately. False, if
the maxmimum number of concurrent tasks was exceeded. If so, you
might consider to use the
addTask(ThreadPool.Task)method instead.
-
getPoolable
-
addTask
Deprecated.No longer in use.Adds a task for immediate or deferred execution.- Parameters:
pTask- The task being added.- Returns:
- True, if the task was started immediately. False, if the task will be executed later.
-
shutdown
public void shutdown()Closes the pool. -
getMaxThreads
public int getMaxThreads()Returns the maximum number of concurrent threads.- Returns:
- Maximum number of threads.
-
getNumThreads
public int getNumThreads()Returns the number of threads, which have actually been created, as opposed to the number of currently running threads.
-