public class StandardThreadExecutor extends LifecycleMBeanBase implements Executor, java.util.concurrent.ExecutorService, ResizableExecutor
Lifecycle.SingleUse| Modifier and Type | Field and Description |
|---|---|
protected boolean |
daemon
Run threads in daemon or non-daemon state
|
protected ThreadPoolExecutor |
executor
The executor we use for this component
|
protected int |
maxIdleTime
idle time in milliseconds
|
protected int |
maxQueueSize
The maximum number of elements that can queue up before we reject them
|
protected int |
maxThreads
max number of threads
|
protected int |
minSpareThreads
min number of threads
|
protected java.lang.String |
name
the name of this thread pool
|
protected java.lang.String |
namePrefix
Default name prefix for the thread name
|
protected static StringManager |
sm |
protected int |
threadPriority
Default thread priority
|
protected long |
threadRenewalDelay
After a context is stopped, threads in the pool are renewed.
|
mserverAFTER_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 and Description |
|---|
StandardThreadExecutor() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
contextStopping() |
void |
execute(java.lang.Runnable command) |
void |
execute(java.lang.Runnable command,
long timeout,
java.util.concurrent.TimeUnit unit)
Deprecated.
|
int |
getActiveCount()
Returns the approximate number of threads that are actively executing
tasks.
|
long |
getCompletedTaskCount() |
int |
getCorePoolSize() |
protected java.lang.String |
getDomainInternal()
Method implemented by sub-classes to identify the domain in which MBeans
should be registered.
|
int |
getLargestPoolSize() |
int |
getMaxIdleTime() |
int |
getMaxQueueSize() |
int |
getMaxThreads() |
int |
getMinSpareThreads() |
java.lang.String |
getName() |
java.lang.String |
getNamePrefix() |
protected java.lang.String |
getObjectNameKeyProperties()
Allow sub-classes to specify the key properties component of the
ObjectName that will be used to register this component. |
int |
getPoolSize()
Returns the current number of threads in the pool.
|
int |
getQueueSize() |
int |
getThreadPriority() |
long |
getThreadRenewalDelay() |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isDaemon() |
boolean |
isShutdown() |
boolean |
isTerminated() |
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 |
setName(java.lang.String name) |
void |
setNamePrefix(java.lang.String namePrefix) |
void |
setThreadPriority(int threadPriority) |
void |
setThreadRenewalDelay(long threadRenewalDelay) |
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
protected void |
startInternal()
Start the component and implement the requirements of
LifecycleBase.startInternal(). |
protected void |
stopInternal()
Stop the component and implement the requirements of
LifecycleBase.stopInternal(). |
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task) |
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task) |
<T> java.util.concurrent.Future<T> |
submit(java.lang.Runnable task,
T result) |
destroyInternal, getDomain, getObjectName, initInternal, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregisteraddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stopprotected static final StringManager sm
protected int threadPriority
protected boolean daemon
protected java.lang.String namePrefix
protected int maxThreads
protected int minSpareThreads
protected int maxIdleTime
protected ThreadPoolExecutor executor
protected java.lang.String name
protected int maxQueueSize
protected long threadRenewalDelay
protected void startInternal()
throws LifecycleException
LifecycleBase.startInternal().startInternal in class LifecycleBaseLifecycleException - if this component detects a fatal error that prevents this component from being
usedprotected void stopInternal()
throws LifecycleException
LifecycleBase.stopInternal().stopInternal in class LifecycleBaseLifecycleException - if this component detects a fatal error that needs to be reported@Deprecated
public void execute(java.lang.Runnable command,
long timeout,
java.util.concurrent.TimeUnit unit)
ExecutorExecutor 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 RejectedExecutionExceptioncommand - the runnable tasktimeout - the length of time to wait for the task to completeunit - the units in which timeout is expressedpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorpublic void contextStopping()
public int getThreadPriority()
public boolean isDaemon()
public java.lang.String getNamePrefix()
public int getMaxIdleTime()
public int getMaxThreads()
getMaxThreads in interface ResizableExecutorpublic int getMinSpareThreads()
public java.lang.String getName()
public void setThreadPriority(int threadPriority)
public void setDaemon(boolean daemon)
public void setNamePrefix(java.lang.String namePrefix)
public void setMaxIdleTime(int maxIdleTime)
public void setMaxThreads(int maxThreads)
public void setMinSpareThreads(int minSpareThreads)
public void setName(java.lang.String name)
public void setMaxQueueSize(int size)
public int getMaxQueueSize()
public long getThreadRenewalDelay()
public void setThreadRenewalDelay(long threadRenewalDelay)
public int getActiveCount()
ResizableExecutorgetActiveCount in interface ResizableExecutorpublic long getCompletedTaskCount()
public int getCorePoolSize()
public int getLargestPoolSize()
public int getPoolSize()
ResizableExecutorgetPoolSize in interface ResizableExecutorpublic int getQueueSize()
public boolean resizePool(int corePoolSize,
int maximumPoolSize)
resizePool in interface ResizableExecutorpublic boolean resizeQueue(int capacity)
resizeQueue in interface ResizableExecutorprotected java.lang.String getDomainInternal()
LifecycleMBeanBasegetDomainInternal in class LifecycleMBeanBaseprotected java.lang.String getObjectNameKeyProperties()
LifecycleMBeanBaseObjectName that will be used to register this component.getObjectNameKeyProperties in class LifecycleMBeanBaseObjectNamepublic void shutdown()
shutdown in interface java.util.concurrent.ExecutorServicepublic java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServicepublic boolean isShutdown()
isShutdown in interface java.util.concurrent.ExecutorServicepublic boolean isTerminated()
isTerminated in interface java.util.concurrent.ExecutorServicepublic boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
awaitTermination in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
submit in interface java.util.concurrent.ExecutorServicepublic <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task,
T result)
submit in interface java.util.concurrent.ExecutorServicepublic java.util.concurrent.Future<?> submit(java.lang.Runnable task)
submit in interface java.util.concurrent.ExecutorServicepublic <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException
invokeAll in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
invokeAll in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionpublic <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
invokeAny in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
invokeAny in interface java.util.concurrent.ExecutorServicejava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionCopyright © 2000-2024 Apache Software Foundation.
Apache Tomcat, Tomcat, Apache, the Apache Tomcat logo and the Apache logo are either registered trademarks or trademarks of the Apache Software Foundation.