public class WorkingGroup<E> extends DynamicThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Constructor and Description |
---|
WorkingGroup(IConsumerObject<E> consumerObject,
int priority,
String wgName,
int minPoolSize,
int maxPoolSize,
long keepAliveTime)
Constructs a working-group that creates new threads as needed, but will reuse previously
constructed threads when they are available.
|
WorkingGroup(IConsumerObject<E> consumerObject,
int priority,
String wgName,
int minPoolSize,
int maxPoolSize,
long keepAliveTime,
int capacity,
long waitTime)
Constructs a working-group that creates new threads as needed, but will reuse previously
constructed threads when they are available.
|
Modifier and Type | Method and Description |
---|---|
void |
enqueueBlocked(E o)
wraps the enqueueBlocked method of the threadpool
|
IConsumerObject<E> |
getConsumerObject() |
String |
getWorkingGroupName() |
boolean |
hasReachedFullCapacity()
Returns true if there are no more idle threads and we have reached the maximum
thread-growth allowed.
|
void |
shutdown()
make a graceful "shutdown" to all the worker threads in the thread pool Initiates an orderly
shutdown in which only executing tasks will complete, previously submitted tasks are
ignored,and no new tasks will be accepted.
|
void |
start()
Start all core threads, causing them to idly wait for work
|
afterExecute, beforeExecute, getActiveCount
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdownNow, terminated, toString
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
public WorkingGroup(IConsumerObject<E> consumerObject, int priority, String wgName, int minPoolSize, int maxPoolSize, long keepAliveTime, int capacity, long waitTime)
Threads are created with priority and named after the working- group name wgName.
The working-group manages a
queue of tasks, which is limited in capacity. If there are no idle threads and the
queue has reached it's capacity the executing thread will block for
waitTime until the task can be queued. A RejectedExecutionException
will be
thrown at the end of the waitTime.
public WorkingGroup(IConsumerObject<E> consumerObject, int priority, String wgName, int minPoolSize, int maxPoolSize, long keepAliveTime)
Threads are created with priority and named after the working- group name wgName.
The working-group manages an
unbound queue of tasks. The executing thread will never block and always favor queuing
if there is no idle thread to handle the task. Equivalent to using a capacity of
Integer.MAX_VALUE
and a waitTime of Long.MAX_VALUE
.
public void start()
public void enqueueBlocked(E o)
public IConsumerObject<E> getConsumerObject()
public void shutdown()
shutdown
in interface ExecutorService
shutdown
in class ThreadPoolExecutor
public String getWorkingGroupName()
public boolean hasReachedFullCapacity()
true
when reached full capacity (i.e. #of active threads equals to the
maximum threads allowed); false
otherwise.Copyright © GigaSpaces.