Apache Tomcat 7.0.28

org.apache.tomcat.util.threads
Class ThreadPoolExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by org.apache.tomcat.util.threads.ThreadPoolExecutor
All Implemented Interfaces:
Executor, ExecutorService

public class ThreadPoolExecutor
extends ThreadPoolExecutor

Same as a java.util.concurrent.ThreadPoolExecutor but implements a much more efficient getSubmittedCount() method, to be used to properly handle the work queue. If a RejectedExecutionHandler is not specified a default one will be configured and that one will always throw a RejectedExecutionException

Author:
fhanik

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
 
Field Summary
protected static StringManager sm
          The string manager for this package.
 
Constructor Summary
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
           
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
           
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
           
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
           
 
Method Summary
protected  void afterExecute(Runnable r, Throwable t)
           
 void contextStopping()
           
protected  boolean currentThreadShouldBeStopped()
           
 void execute(Runnable command)
          
 void execute(Runnable command, long timeout, TimeUnit unit)
          Executes the given command at some time in the future.
 int getSubmittedCount()
           
 long getThreadRenewalDelay()
           
 void setThreadRenewalDelay(long threadRenewalDelay)
           
protected  void stopCurrentThreadIfNeeded()
          If the current thread was started before the last time when a context was stopped, an exception is thrown so that the current thread is stopped.
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
 
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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sm

protected static final StringManager sm
The string manager for this package.

Constructor Detail

ThreadPoolExecutor

public ThreadPoolExecutor(int corePoolSize,
                          int maximumPoolSize,
                          long keepAliveTime,
                          TimeUnit unit,
                          BlockingQueue<Runnable> workQueue,
                          RejectedExecutionHandler handler)

ThreadPoolExecutor

public ThreadPoolExecutor(int corePoolSize,
                          int maximumPoolSize,
                          long keepAliveTime,
                          TimeUnit unit,
                          BlockingQueue<Runnable> workQueue,
                          ThreadFactory threadFactory,
                          RejectedExecutionHandler handler)

ThreadPoolExecutor

public ThreadPoolExecutor(int corePoolSize,
                          int maximumPoolSize,
                          long keepAliveTime,
                          TimeUnit unit,
                          BlockingQueue<Runnable> workQueue,
                          ThreadFactory threadFactory)

ThreadPoolExecutor

public ThreadPoolExecutor(int corePoolSize,
                          int maximumPoolSize,
                          long keepAliveTime,
                          TimeUnit unit,
                          BlockingQueue<Runnable> workQueue)
Method Detail

getThreadRenewalDelay

public long getThreadRenewalDelay()

setThreadRenewalDelay

public void setThreadRenewalDelay(long threadRenewalDelay)

afterExecute

protected void afterExecute(Runnable r,
                            Throwable t)
Overrides:
afterExecute in class ThreadPoolExecutor

stopCurrentThreadIfNeeded

protected void stopCurrentThreadIfNeeded()
If the current thread was started before the last time when a context was stopped, an exception is thrown so that the current thread is stopped.


currentThreadShouldBeStopped

protected boolean currentThreadShouldBeStopped()

getSubmittedCount

public int getSubmittedCount()

execute

public void execute(Runnable command)

Specified by:
execute in interface Executor
Overrides:
execute in class ThreadPoolExecutor

execute

public void execute(Runnable command,
                    long timeout,
                    TimeUnit unit)
Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation. If no threads are available, it will be added to the work queue. If the work queue is full, the system will wait for the specified time and it throw a RejectedExecutionException if the queue is still full after that.

Parameters:
command - the runnable task
Throws:
RejectedExecutionException - if this task cannot be accepted for execution - the queue is full
NullPointerException - if command or unit is null

contextStopping

public void contextStopping()

Apache Tomcat 7.0.28

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.