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

# Class StandardVirtualThreadExecutor

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

All Implemented Interfaces:
  `AutoCloseable, Executor, ExecutorService, MBeanRegistration, Executor, JmxEnabled, Lifecycle`

public class StandardVirtualThreadExecutor extends LifecycleMBeanBase implements Executor, ExecutorService
An executor that uses a new virtual thread for each task.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Lifecycle

  `Lifecycle.SingleUse`

- ## Field Summary

  ### 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
  `StandardVirtualThreadExecutor()`
  Default constructor required for the Digester.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `awaitTermination(long timeout, TimeUnit unit)`
  `void`
  `execute(Runnable command)`
  `protected String`
  `getDomainInternal()`
  Method implemented by subclasses to identify the domain in which MBeans should be registered.
  `String`
  `getName()`
  Returns the name of this executor.
  `String`
  `getNamePrefix()`
  Return the name prefix for virtual threads.
  `protected String`
  `getObjectNameKeyProperties()`
  Allow subclasses to specify the key properties component of the `ObjectName` that will be used to register this component.
  `protected void`
  `initInternal()`
  Subclasses implement this method to perform any instance initialisation required.
  `<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`
  `isShutdown()`
  `boolean`
  `isTerminated()`
  `void`
  `setName(String name)`
  Set the name for this executor.
  `void`
  `setNamePrefix(String namePrefix)`
  Set the name prefix for virtual threads.
  `void`
  `shutdown()`
  `List<Runnable>`
  `shutdownNow()`
  `protected void`
  `startInternal()`
  Subclasses must ensure that the state is changed to `LifecycleState.STARTING` during the execution of this method.
  `protected void`
  `stopInternal()`
  Subclasses must ensure that the state is changed to `LifecycleState.STOPPING` during the execution of this method.
  `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, 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`

- ## Constructor Details

  - ### StandardVirtualThreadExecutor

    public StandardVirtualThreadExecutor()
    Default constructor required for the Digester.

- ## Method Details

  - ### setName

    public void setName(String name)
    Set the name for this executor.
    Parameters:
      `name` - the executor name

  - ### getName

    public String getName()
    Description copied from interface: `Executor`
    Returns the name of this executor.
    Specified by:
      `getName` in interface `Executor`
    Returns:
      the executor name

  - ### getNamePrefix

    public String getNamePrefix()
    Return the name prefix for virtual threads.
    Returns:
      the name prefix

  - ### setNamePrefix

    public void setNamePrefix(String namePrefix)
    Set the name prefix for virtual threads.
    Parameters:
      `namePrefix` - the name prefix

  - ### execute

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

  - ### initInternal

    protected void initInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses implement this method to perform any instance initialisation required.
    Overrides:
      `initInternal` in class `LifecycleMBeanBase`
    Throws:
      `LifecycleException` - If the initialisation fails

  - ### startInternal

    protected void startInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses must ensure that the state is changed to `LifecycleState.STARTING` during the execution of this method. Changing state will trigger the `Lifecycle.START_EVENT` event. If a component fails to start it may either throw a `LifecycleException` which will cause it's parent to fail to start, or it can place itself in the error state in which case `LifecycleBase.stop()` will be called on the failed component but the parent component will continue to start normally.
    Specified by:
      `startInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - Start error occurred

  - ### stopInternal

    protected void stopInternal() throws LifecycleException
    Description copied from class: `LifecycleBase`
    Subclasses must ensure that the state is changed to `LifecycleState.STOPPING` during the execution of this method. Changing state will trigger the `Lifecycle.STOP_EVENT` event.
    Specified by:
      `stopInternal` in class `LifecycleBase`
    Throws:
      `LifecycleException` - Stop error occurred

  - ### 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`