|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sblim.cimclient.internal.util.ThreadPool
public class ThreadPool
Class ThreadPool implements a pool that manages threads and executes submitted tasks using this threads.
Constructor Summary | |
---|---|
ThreadPool(int pMinPoolSize,
int pMaxPoolSize,
int pToleratedBacklog,
long pToleratedIdle,
ThreadGroup pGroup,
String pWorkerName)
Ctor |
Method Summary | |
---|---|
boolean |
execute(Runnable task,
boolean enqueue)
Submits a task for execution |
protected ThreadGroup |
getGroup()
Gets the associated thread group |
long |
getIdleTimeOutMs()
Returns the idle timeout |
protected void |
removeThread(org.sblim.cimclient.internal.util.ThreadPool.Worker worker)
Removes a worker from the pool. |
void |
shutdown()
Shuts down the thread pool and all workers |
boolean |
taskCompleted(org.sblim.cimclient.internal.util.ThreadPool.Worker worker,
boolean timedOut)
Used by the worker to report task completion and ask for a new task |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ThreadPool(int pMinPoolSize, int pMaxPoolSize, int pToleratedBacklog, long pToleratedIdle, ThreadGroup pGroup, String pWorkerName)
pMinPoolSize
- The minimal pool size. The pool will always keep at least this
number of worker threads alive even in no load situations.pMaxPoolSize
- The maximal pool size. The pool will create up to that number
of worker threads on heavy load.pToleratedBacklog
- The task backlog that is tolerated before an additional worker
is createdpToleratedIdle
- The idle time of a worker that is tolerated before the worker
is destroyedpGroup
- Then thread group to put the worker threads inpWorkerName
- The name to use for worker threadsMethod Detail |
---|
public long getIdleTimeOutMs()
public boolean execute(Runnable task, boolean enqueue)
task
- The taskenqueue
- if true
the task will be enqueued if no worker is
free, otherwise the task is executed immediately or not at
all.
true
if the task was executed or enqueued,
false
otherwise.protected ThreadGroup getGroup()
public boolean taskCompleted(org.sblim.cimclient.internal.util.ThreadPool.Worker worker, boolean timedOut)
worker
- The workertimedOut
- true
if the worker has been idle and reached
timeout
true
if the worker shall stay alive,
false
if it shall shut down itselfprotected void removeThread(org.sblim.cimclient.internal.util.ThreadPool.Worker worker)
worker
- The workerpublic void shutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |