|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.concurrent.AbstractExecutorService
com.sun.grizzly.util.AbstractThreadPool
com.sun.grizzly.util.SyncThreadPool
public class SyncThreadPool
ExecutorService
implementation, which function the similar way as
former Grizzly 1.x Pipeline based thread pools.
The SyncThreadPool is sychronized similar way as Grizzly 1.x Pipeline,
which makes thread pool more accurate when deciding to create or not
additional worker threads.
Nested Class Summary | |
---|---|
protected class |
SyncThreadPool.SyncThreadWorker
|
Nested classes/interfaces inherited from class com.sun.grizzly.util.AbstractThreadPool |
---|
AbstractThreadPool.Worker |
Field Summary | |
---|---|
protected int |
maxQueuedTasks
|
Fields inherited from class com.sun.grizzly.util.AbstractThreadPool |
---|
activeThreadsCount, byteBufferType, corePoolSize, currentPoolSize, DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT, DEFAULT_MAX_TASKS_QUEUED, DEFAULT_MAX_THREAD_COUNT, DEFAULT_MIN_THREAD_COUNT, initialByteBufferSize, keepAliveTime, maxPoolSize, name, poison, priority, probe, running, statelock, threadFactory, workers |
Constructor Summary | |
---|---|
SyncThreadPool()
|
|
SyncThreadPool(String name,
int corePoolsize,
int maxPoolSize,
long keepAliveTime,
TimeUnit timeUnit)
|
|
SyncThreadPool(String name,
int corePoolsize,
int maxPoolSize,
long keepAliveTime,
TimeUnit timeUnit,
ThreadFactory threadFactory)
|
|
SyncThreadPool(String name,
int corePoolsize,
int maxPoolSize,
long keepAliveTime,
TimeUnit timeUnit,
ThreadFactory threadFactory,
Queue<Runnable> workQueue,
int maxQueuedTasks)
|
|
SyncThreadPool(String name,
int corePoolsize,
int maxPoolSize,
long keepAliveTime,
TimeUnit timeUnit,
ThreadFactory threadFactory,
Queue<Runnable> workQueue,
int maxQueuedTasks,
ThreadPoolMonitoringProbe probe)
|
Method Summary | |
---|---|
protected void |
afterExecute(Thread thread,
Runnable r,
Throwable t)
Method invoked upon completion of execution of the given Runnable. |
boolean |
awaitTermination(long timeout,
TimeUnit unit)
|
void |
execute(Runnable task)
|
int |
getActiveCount()
Returns the approximate number of threads that are actively executing tasks. |
long |
getCompletedTaskCount()
Returns the approximate total number of tasks that have completed execution. |
int |
getLargestPoolSize()
Returns the largest number of threads that have ever simultaneously been in the pool. |
int |
getMaxQueuedTasksCount()
|
int |
getPoolSize()
Returns the current number of threads in the pool. |
Queue<Runnable> |
getQueue()
Returns the task queue used by this executor. |
int |
getQueueSize()
Returns the number of tasks, which are currently waiting in the queue. |
int |
getTaskCount()
Returns the approximate total number of tasks that have been scheduled for execution. |
boolean |
isTerminated()
|
protected void |
poisonAll()
|
void |
setMaxQueuedTasksCount(int maxQueuedTasks)
|
protected void |
setPoolSizes(int corePoolSize,
int maxPoolSize)
|
void |
start()
|
protected void |
startWorker(AbstractThreadPool.Worker wt)
must hold statelock while calling this method. |
void |
stop()
|
String |
toString()
|
Methods inherited from class java.util.concurrent.AbstractExecutorService |
---|
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.concurrent.ExecutorService |
---|
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit |
Field Detail |
---|
protected int maxQueuedTasks
Constructor Detail |
---|
public SyncThreadPool()
public SyncThreadPool(String name, int corePoolsize, int maxPoolSize, long keepAliveTime, TimeUnit timeUnit)
name
- corePoolsize
- maxPoolSize
- keepAliveTime
- timeUnit
- TimeUnit
public SyncThreadPool(String name, int corePoolsize, int maxPoolSize, long keepAliveTime, TimeUnit timeUnit, ThreadFactory threadFactory)
name
- corePoolsize
- maxPoolSize
- keepAliveTime
- timeUnit
- TimeUnit
threadFactory
- ThreadFactory
public SyncThreadPool(String name, int corePoolsize, int maxPoolSize, long keepAliveTime, TimeUnit timeUnit, ThreadFactory threadFactory, Queue<Runnable> workQueue, int maxQueuedTasks)
name
- corePoolsize
- maxPoolSize
- keepAliveTime
- timeUnit
- TimeUnit
threadFactory
- ThreadFactory
workQueue
- BlockingQueue
maxQueuedTasks
- public SyncThreadPool(String name, int corePoolsize, int maxPoolSize, long keepAliveTime, TimeUnit timeUnit, ThreadFactory threadFactory, Queue<Runnable> workQueue, int maxQueuedTasks, ThreadPoolMonitoringProbe probe)
name
- corePoolsize
- maxPoolSize
- keepAliveTime
- timeUnit
- threadFactory
- workQueue
- maxQueuedTasks
- probe
- Method Detail |
---|
public void start()
public void stop()
public void execute(Runnable task)
protected void startWorker(AbstractThreadPool.Worker wt)
startWorker
in class AbstractThreadPool
wt
- public boolean isTerminated()
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
InterruptedException
public int getActiveCount()
public int getTaskCount()
public long getCompletedTaskCount()
public int getLargestPoolSize()
public int getPoolSize()
public Queue<Runnable> getQueue()
public int getQueueSize()
public int getMaxQueuedTasksCount()
public void setMaxQueuedTasksCount(int maxQueuedTasks)
protected void setPoolSizes(int corePoolSize, int maxPoolSize)
protected void afterExecute(Thread thread, Runnable r, Throwable t)
AbstractThreadPool
Note: When actions are enclosed in tasks (such as
FutureTask
) either explicitly or via methods such as
submit, these task objects catch and maintain
computational exceptions, and so they do not cause abrupt
termination, and the internal exceptions are not
passed to this method.
This implementation does nothing, but may be customized in subclasses. Note: To properly nest multiple overridings, subclasses should generally invoke super.afterExecute at the beginning of this method.
afterExecute
in class AbstractThreadPool
r
- the runnable that has completed.t
- the exception that caused termination, or null if
execution completed normally.protected void poisonAll()
poisonAll
in class AbstractThreadPool
public String toString()
toString
in class AbstractThreadPool
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |