Package org.apache.catalina.core
Class StandardThreadExecutor
java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.core.StandardThreadExecutor
- All Implemented Interfaces:
Executor
,ExecutorService
,MBeanRegistration
,Executor
,JmxEnabled
,Lifecycle
,ResizableExecutor
public class StandardThreadExecutor
extends LifecycleMBeanBase
implements Executor, ExecutorService, ResizableExecutor
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
Lifecycle.SingleUse
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Run threads in daemon or non-daemon stateprotected ThreadPoolExecutor
The executor we use for this componentprotected int
idle time in millisecondsprotected int
The maximum number of elements that can queue up before we reject themprotected int
max number of threadsprotected int
min number of threadsprotected String
the name of this thread poolprotected String
Default name prefix for the thread nameprotected static final StringManager
protected int
Default thread priorityprotected long
After a context is stopped, threads in the pool are renewed.Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase
mserver
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
awaitTermination
(long timeout, TimeUnit unit) void
void
void
Deprecated.int
Returns the approximate number of threads that are actively executing tasks.long
int
protected String
Method implemented by sub-classes to identify the domain in which MBeans should be registered.int
int
int
int
int
getName()
protected String
Allow sub-classes to specify the key properties component of theObjectName
that will be used to register this component.int
Returns the current number of threads in the pool.int
int
long
invokeAll
(Collection<? extends Callable<T>> tasks) invokeAll
(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> T
invokeAny
(Collection<? extends Callable<T>> tasks) <T> T
invokeAny
(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) boolean
isDaemon()
boolean
boolean
boolean
resizePool
(int corePoolSize, int maximumPoolSize) boolean
resizeQueue
(int capacity) void
setDaemon
(boolean daemon) void
setMaxIdleTime
(int maxIdleTime) void
setMaxQueueSize
(int size) void
setMaxThreads
(int maxThreads) void
setMinSpareThreads
(int minSpareThreads) void
void
setNamePrefix
(String namePrefix) void
setThreadPriority
(int threadPriority) void
setThreadRenewalDelay
(long threadRenewalDelay) void
shutdown()
protected void
Start the component and implement the requirements ofLifecycleBase.startInternal()
.protected void
Stop the component and implement the requirements ofLifecycleBase.stopInternal()
.Future<?>
<T> Future<T>
<T> Future<T>
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, initInternal, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
Methods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.catalina.Lifecycle
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
-
Field Details
-
sm
-
threadPriority
protected int threadPriorityDefault thread priority -
daemon
protected boolean daemonRun threads in daemon or non-daemon state -
namePrefix
Default name prefix for the thread name -
maxThreads
protected int maxThreadsmax number of threads -
minSpareThreads
protected int minSpareThreadsmin number of threads -
maxIdleTime
protected int maxIdleTimeidle time in milliseconds -
executor
The executor we use for this component -
name
the name of this thread pool -
maxQueueSize
protected int maxQueueSizeThe maximum number of elements that can queue up before we reject them -
threadRenewalDelay
protected long threadRenewalDelayAfter a context is stopped, threads in the pool are renewed. To avoid renewing all threads at the same time, this delay is observed between 2 threads being renewed.
-
-
Constructor Details
-
StandardThreadExecutor
public StandardThreadExecutor()
-
-
Method Details
-
startInternal
Start the component and implement the requirements ofLifecycleBase.startInternal()
.- Specified by:
startInternal
in classLifecycleBase
- Throws:
LifecycleException
- if this component detects a fatal error that prevents this component from being used
-
stopInternal
Stop the component and implement the requirements ofLifecycleBase.stopInternal()
.- Specified by:
stopInternal
in classLifecycleBase
- Throws:
LifecycleException
- if this component detects a fatal error that needs to be reported
-
execute
Deprecated.Description copied from interface:Executor
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 theExecutor
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 until it throws a RejectedExecutionException -
execute
-
contextStopping
public void contextStopping() -
getThreadPriority
public int getThreadPriority() -
isDaemon
public boolean isDaemon() -
getNamePrefix
-
getMaxIdleTime
public int getMaxIdleTime() -
getMaxThreads
public int getMaxThreads()- Specified by:
getMaxThreads
in interfaceResizableExecutor
-
getMinSpareThreads
public int getMinSpareThreads() -
getName
-
setThreadPriority
public void setThreadPriority(int threadPriority) -
setDaemon
public void setDaemon(boolean daemon) -
setNamePrefix
-
setMaxIdleTime
public void setMaxIdleTime(int maxIdleTime) -
setMaxThreads
public void setMaxThreads(int maxThreads) -
setMinSpareThreads
public void setMinSpareThreads(int minSpareThreads) -
setName
-
setMaxQueueSize
public void setMaxQueueSize(int size) -
getMaxQueueSize
public int getMaxQueueSize() -
getThreadRenewalDelay
public long getThreadRenewalDelay() -
setThreadRenewalDelay
public void setThreadRenewalDelay(long threadRenewalDelay) -
getActiveCount
public int getActiveCount()Description copied from interface:ResizableExecutor
Returns the approximate number of threads that are actively executing tasks.- Specified by:
getActiveCount
in interfaceResizableExecutor
- Returns:
- the number of threads
-
getCompletedTaskCount
public long getCompletedTaskCount() -
getCorePoolSize
public int getCorePoolSize() -
getLargestPoolSize
public int getLargestPoolSize() -
getPoolSize
public int getPoolSize()Description copied from interface:ResizableExecutor
Returns the current number of threads in the pool.- Specified by:
getPoolSize
in interfaceResizableExecutor
- Returns:
- the number of threads
-
getQueueSize
public int getQueueSize() -
resizePool
public boolean resizePool(int corePoolSize, int maximumPoolSize) - Specified by:
resizePool
in interfaceResizableExecutor
-
resizeQueue
public boolean resizeQueue(int capacity) - Specified by:
resizeQueue
in interfaceResizableExecutor
-
getDomainInternal
Description copied from class:LifecycleMBeanBase
Method implemented by sub-classes to identify the domain in which MBeans should be registered.- Specified by:
getDomainInternal
in classLifecycleMBeanBase
- Returns:
- The name of the domain to use to register MBeans.
-
getObjectNameKeyProperties
Description copied from class:LifecycleMBeanBase
Allow sub-classes to specify the key properties component of theObjectName
that will be used to register this component.- Specified by:
getObjectNameKeyProperties
in classLifecycleMBeanBase
- Returns:
- The string representation of the key properties component of the desired
ObjectName
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNow
in interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminated
in interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
TimeoutException
-