|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.concurrent.AbstractExecutorService
org.glassfish.grizzly.threadpool.AbstractThreadPool
public abstract class AbstractThreadPool
Abstract ExecutorService implementation.
| Nested Class Summary | |
|---|---|
class |
AbstractThreadPool.Worker
|
| Field Summary | |
|---|---|
protected ThreadPoolConfig |
config
|
static int |
DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT
|
static int |
DEFAULT_MAX_TASKS_QUEUED
|
static int |
DEFAULT_MAX_THREAD_COUNT
|
static int |
DEFAULT_MIN_THREAD_COUNT
|
protected DelayedExecutor.DelayQueue<AbstractThreadPool.Worker> |
delayedQueue
|
protected AbstractJmxMonitoringConfig<ThreadPoolProbe> |
monitoringConfig
ThreadPool probes |
protected static java.lang.Runnable |
poison
|
protected boolean |
running
|
protected java.util.concurrent.locks.ReentrantLock |
stateLock
|
protected java.util.concurrent.locks.Condition |
stateLockCondition
Wait condition to support awaitTermination |
protected long |
transactionTimeoutMillis
|
protected java.util.Map<AbstractThreadPool.Worker,java.lang.Long> |
workers
|
| Constructor Summary | |
|---|---|
AbstractThreadPool(ThreadPoolConfig config)
|
|
| Method Summary | |
|---|---|
protected void |
afterExecute(AbstractThreadPool.Worker worker,
java.lang.Thread thread,
java.lang.Runnable r,
java.lang.Throwable t)
Method invoked upon completion of execution of the given Runnable. |
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
|
protected void |
beforeExecute(AbstractThreadPool.Worker worker,
java.lang.Thread t,
java.lang.Runnable r)
Method invoked prior to executing the given Runnable in the given thread. |
protected static void |
drain(java.util.Queue<java.lang.Runnable> from,
java.util.Collection<java.lang.Runnable> to)
|
ThreadPoolConfig |
getConfig()
|
protected java.util.concurrent.ThreadFactory |
getDefaultThreadFactory()
|
JmxMonitoringConfig<ThreadPoolProbe> |
getMonitoringConfig()
Return the object associated JmxMonitoringConfig. |
java.util.Queue<java.lang.Runnable> |
getQueue()
|
boolean |
isShutdown()
|
boolean |
isTerminated()
|
protected java.lang.String |
nextThreadId()
|
protected void |
onMaxNumberOfThreadsReached()
Method is called by AbstractThreadPool, when maximum number of worker threads is reached and task will need to wait in task queue, until one of the threads will be able to process it. |
protected void |
onTaskCompletedEvent(java.lang.Runnable task)
This method will be invoked when a the specified Runnable has
completed execution. |
protected void |
onTaskDequeued(java.lang.Runnable task)
Method is called by a thread pool each time a task has been dequeued from a task queue. |
protected void |
onTaskQueued(java.lang.Runnable task)
Method is called by a thread pool each time new task has been queued to a task queue. |
protected void |
onTaskQueueOverflow()
Method is called by a thread pool, when new task could not be added to a task queue, because task queue is full. |
protected void |
onWorkerExit(AbstractThreadPool.Worker worker)
Method is called by AbstractThreadPool.Worker, when it's completing
AbstractThreadPool.Worker.run() method execution, which in most cases means,
that ThreadPool's thread will be released. |
protected void |
onWorkerStarted(AbstractThreadPool.Worker worker)
Method is called by AbstractThreadPool.Worker, when it's starting
AbstractThreadPool.Worker.run() method execution, which means, that ThreadPool's
thread is getting active and ready to process tasks. |
protected void |
poisonAll()
|
void |
shutdown()
|
java.util.List<java.lang.Runnable> |
shutdownNow()
|
protected void |
startWorker(AbstractThreadPool.Worker worker)
must hold statelock while calling this method. |
java.lang.String |
toString()
|
void |
uncaughtException(java.lang.Thread thread,
java.lang.Throwable throwable)
|
protected void |
validateNewPoolSize(int corePoolsize,
int maxPoolSize)
|
| 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.Executor |
|---|
execute |
| Field Detail |
|---|
public static final int DEFAULT_MIN_THREAD_COUNT
public static final int DEFAULT_MAX_THREAD_COUNT
public static final int DEFAULT_MAX_TASKS_QUEUED
public static final int DEFAULT_IDLE_THREAD_KEEPALIVE_TIMEOUT
protected static final java.lang.Runnable poison
protected final java.util.concurrent.locks.ReentrantLock stateLock
protected final java.util.concurrent.locks.Condition stateLockCondition
protected final java.util.Map<AbstractThreadPool.Worker,java.lang.Long> workers
protected volatile boolean running
protected final ThreadPoolConfig config
protected final long transactionTimeoutMillis
protected final DelayedExecutor.DelayQueue<AbstractThreadPool.Worker> delayedQueue
protected final AbstractJmxMonitoringConfig<ThreadPoolProbe> monitoringConfig
| Constructor Detail |
|---|
public AbstractThreadPool(ThreadPoolConfig config)
| Method Detail |
|---|
protected void startWorker(AbstractThreadPool.Worker worker)
worker - public ThreadPoolConfig getConfig()
public java.util.Queue<java.lang.Runnable> getQueue()
public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServicepublic void shutdown()
shutdown in interface java.util.concurrent.ExecutorServicepublic boolean isShutdown()
isShutdown in interface java.util.concurrent.ExecutorServicepublic boolean isTerminated()
isTerminated in interface java.util.concurrent.ExecutorService
public boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
awaitTermination in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionprotected void poisonAll()
protected static void drain(java.util.Queue<java.lang.Runnable> from,
java.util.Collection<java.lang.Runnable> to)
protected java.lang.String nextThreadId()
protected void validateNewPoolSize(int corePoolsize,
int maxPoolSize)
protected void beforeExecute(AbstractThreadPool.Worker worker,
java.lang.Thread t,
java.lang.Runnable r)
This implementation does nothing, but may be customized in subclasses. Note: To properly nest multiple overridings, subclasses should generally invoke super.beforeExecute at the end of this method.
worker - the AbstractThreadPool.Worker, running the the thread tt - the thread that will run task r.r - the task that will be executed.
protected void afterExecute(AbstractThreadPool.Worker worker,
java.lang.Thread thread,
java.lang.Runnable r,
java.lang.Throwable t)
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.
worker - the AbstractThreadPool.Worker, running the the thread tthread - r - the runnable that has completed.t - the exception that caused termination, or null if
execution completed normally.protected void onTaskCompletedEvent(java.lang.Runnable task)
This method will be invoked when a the specified Runnable has
completed execution.
task - the unit of work that has completed processingprotected void onWorkerStarted(AbstractThreadPool.Worker worker)
AbstractThreadPool.Worker, when it's starting
AbstractThreadPool.Worker.run() method execution, which means, that ThreadPool's
thread is getting active and ready to process tasks.
This method is called from AbstractThreadPool.Worker's thread.
worker - protected void onWorkerExit(AbstractThreadPool.Worker worker)
AbstractThreadPool.Worker, when it's completing
AbstractThreadPool.Worker.run() method execution, which in most cases means,
that ThreadPool's thread will be released. This method is called from
AbstractThreadPool.Worker's thread.
worker - protected void onMaxNumberOfThreadsReached()
protected void onTaskQueued(java.lang.Runnable task)
task - protected void onTaskDequeued(java.lang.Runnable task)
task - protected void onTaskQueueOverflow()
RejectedExecutionException
public JmxMonitoringConfig<ThreadPoolProbe> getMonitoringConfig()
JmxMonitoringConfig.
getMonitoringConfig in interface JmxMonitoringAware<ThreadPoolProbe>getMonitoringConfig in interface MonitoringAware<ThreadPoolProbe>JmxMonitoringConfig.
public void uncaughtException(java.lang.Thread thread,
java.lang.Throwable throwable)
uncaughtException in interface java.lang.Thread.UncaughtExceptionHandlerprotected java.util.concurrent.ThreadFactory getDefaultThreadFactory()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||