StandardThreadExecutor (Apache Tomcat 10.1.48 API Documentation)
Description: declaration: package: org.apache.catalina.core, class: StandardThreadExecutor

# Class StandardThreadExecutor

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.core.StandardThreadExecutor

All Implemented Interfaces:
  `AutoCloseable, 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 Lifecycle

  `Lifecycle.SingleUse`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  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 String`
  `name`
  the name of this thread pool
  `protected String`
  `namePrefix`
  Default name prefix for the thread name
  `protected static final StringManager`
  `sm`
  `protected int`
  `threadPriority`
  Default thread priority
  `protected long`
  `threadRenewalDelay`
  After a context is stopped, threads in the pool are renewed.

  ### Fields inherited from interface 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

  Constructors
  Constructor
  Description
  `StandardThreadExecutor()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `awaitTermination(long timeout, TimeUnit unit)`
  `void`
  `contextStopping()`
  `void`
  `execute(Runnable command)`
  `int`
  `getActiveCount()`
  Returns the approximate number of threads that are actively executing tasks.
  `long`
  `getCompletedTaskCount()`
  `int`
  `getCorePoolSize()`
  `protected String`
  `getDomainInternal()`
  Method implemented by subclasses to identify the domain in which MBeans should be registered.
  `int`
  `getLargestPoolSize()`
  `int`
  `getMaxIdleTime()`
  `int`
  `getMaxQueueSize()`
  `int`
  `getMaxThreads()`
  `int`
  `getMinSpareThreads()`
  `String`
  `getName()`
  `String`
  `getNamePrefix()`
  `protected String`
  `getObjectNameKeyProperties()`
  Allow subclasses 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> List<Future<T>>`
  `invokeAll(Collection<? extends Callable<T>> tasks)`
  `<T> List<Future<T>>`
  `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`
  `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(String name)`
  `void`
  `setNamePrefix(String namePrefix)`
  `void`
  `setThreadPriority(int threadPriority)`
  `void`
  `setThreadRenewalDelay(long threadRenewalDelay)`
  `void`
  `shutdown()`
  `List<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()`.
  `Future<?>`
  `submit(Runnable task)`
  `<T> Future<T>`
  `submit(Runnable task, T result)`
  `<T> Future<T>`
  `submit(Callable<T> task)`

  ### Methods inherited from class LifecycleMBeanBase

  `destroyInternal, getDomain, getObjectName, initInternal, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister`

  ### Methods inherited from class LifecycleBase

  `addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface ExecutorService

  `close`

  ### Methods inherited from interface Lifecycle

  `addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop`

- ## Field Details

  - ### sm

    protected static final StringManager sm

  - ### threadPriority

    protected int threadPriority
    Default thread priority

  - ### daemon

    protected boolean daemon
    Run threads in daemon or non-daemon state

  - ### namePrefix

    protected String namePrefix
    Default name prefix for the thread name

  - ### maxThreads

    protected int maxThreads
    max number of threads

  - ### minSpareThreads

    protected int minSpareThreads
    min number of threads

  - ### maxIdleTime

    protected int maxIdleTime
    idle time in milliseconds

  - ### executor

    protected ThreadPoolExecutor executor
    The executor we use for this component

  - ### name

    protected String name
    the name of this thread pool

  - ### maxQueueSize

    protected int maxQueueSize
    The maximum number of elements that can queue up before we reject them

  - ### threadRenewalDelay

    protected long threadRenewalDelay
    After 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

    protected void startInternal() throws LifecycleException
    Start the component and implement the requirements of `LifecycleBase.startInternal()`.
    Specified by:
      `startInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - if this component detects a fatal error that prevents this component from being used

  - ### stopInternal

    protected void stopInternal() throws LifecycleException
    Stop the component and implement the requirements of `LifecycleBase.stopInternal()`.
    Specified by:
      `stopInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - if this component detects a fatal error that needs to be reported

  - ### execute

    public void execute(Runnable command)
    Specified by:
      `execute` in interface `Executor`

  - ### contextStopping

    public void contextStopping()

  - ### getThreadPriority

    public int getThreadPriority()

  - ### isDaemon

    public boolean isDaemon()

  - ### getNamePrefix

    public String getNamePrefix()

  - ### getMaxIdleTime

    public int getMaxIdleTime()

  - ### getMaxThreads

    public int getMaxThreads()
    Specified by:
      `getMaxThreads` in interface `ResizableExecutor`

  - ### getMinSpareThreads

    public int getMinSpareThreads()

  - ### getName

    public String getName()
    Specified by:
      `getName` in interface `Executor`

  - ### setThreadPriority

    public void setThreadPriority(int threadPriority)

  - ### setDaemon

    public void setDaemon(boolean daemon)

  - ### setNamePrefix

    public void setNamePrefix(String namePrefix)

  - ### setMaxIdleTime

    public void setMaxIdleTime(int maxIdleTime)

  - ### setMaxThreads

    public void setMaxThreads(int maxThreads)

  - ### setMinSpareThreads

    public void setMinSpareThreads(int minSpareThreads)

  - ### setName

    public void setName(String name)

  - ### 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 interface `ResizableExecutor`
    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 interface `ResizableExecutor`
    Returns:
      the number of threads

  - ### getQueueSize

    public int getQueueSize()

  - ### resizePool

    public boolean resizePool(int corePoolSize, int maximumPoolSize)
    Specified by:
      `resizePool` in interface `ResizableExecutor`

  - ### resizeQueue

    public boolean resizeQueue(int capacity)
    Specified by:
      `resizeQueue` in interface `ResizableExecutor`

  - ### getDomainInternal

    protected String getDomainInternal()
    Description copied from class: `LifecycleMBeanBase`
    Method implemented by subclasses to identify the domain in which MBeans should be registered.
    Specified by:
      `getDomainInternal` in class `LifecycleMBeanBase`
    Returns:
      The name of the domain to use to register MBeans.

  - ### getObjectNameKeyProperties

    protected String getObjectNameKeyProperties()
    Description copied from class: `LifecycleMBeanBase`
    Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
    Specified by:
      `getObjectNameKeyProperties` in class `LifecycleMBeanBase`
    Returns:
      The string representation of the key properties component of the desired `ObjectName`

  - ### shutdown

    public void shutdown()
    Specified by:
      `shutdown` in interface `ExecutorService`

  - ### shutdownNow

    public List<Runnable> shutdownNow()
    Specified by:
      `shutdownNow` in interface `ExecutorService`

  - ### isShutdown

    public boolean isShutdown()
    Specified by:
      `isShutdown` in interface `ExecutorService`

  - ### isTerminated

    public boolean isTerminated()
    Specified by:
      `isTerminated` in interface `ExecutorService`

  - ### awaitTermination

    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
    Specified by:
      `awaitTermination` in interface `ExecutorService`
    Throws:
      `InterruptedException`

  - ### submit

    public <T> Future<T> submit(Callable<T> task)
    Specified by:
      `submit` in interface `ExecutorService`

  - ### submit

    public <T> Future<T> submit(Runnable task, T result)
    Specified by:
      `submit` in interface `ExecutorService`

  - ### submit

    public Future<?> submit(Runnable task)
    Specified by:
      `submit` in interface `ExecutorService`

  - ### invokeAll

    public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
    Specified by:
      `invokeAll` in interface `ExecutorService`
    Throws:
      `InterruptedException`

  - ### invokeAll

    public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
    Specified by:
      `invokeAll` in interface `ExecutorService`
    Throws:
      `InterruptedException`

  - ### invokeAny

    public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
    Specified by:
      `invokeAny` in interface `ExecutorService`
    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 interface `ExecutorService`
    Throws:
      `InterruptedException`
      `ExecutionException`
      `TimeoutException`