VirtualThreadExecutor (Apache Tomcat 11.0.23 API Documentation)
Description: declaration: package: org.apache.tomcat.util.threads, class: VirtualThreadExecutor

# Class VirtualThreadExecutor

java.lang.Object
java.util.concurrent.AbstractExecutorService
org.apache.tomcat.util.threads.VirtualThreadExecutor

All Implemented Interfaces:
  `AutoCloseable, Executor, ExecutorService`

public class VirtualThreadExecutor extends AbstractExecutorService
An executor that uses a new virtual thread for each task.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VirtualThreadExecutor(String namePrefix)`
  Constructs a new VirtualThreadExecutor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `awaitTermination(long timeout, TimeUnit unit)`
  `void`
  `execute(Runnable command)`
  `boolean`
  `isShutdown()`
  `boolean`
  `isTerminated()`
  `void`
  `shutdown()`
  `List<Runnable>`
  `shutdownNow()`

  ### Methods inherited from class AbstractExecutorService

  `invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit`

  ### Methods inherited from class Object

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

  ### Methods inherited from interface ExecutorService

  `close`

- ## Constructor Details

  - ### VirtualThreadExecutor

    public VirtualThreadExecutor(String namePrefix)
    Constructs a new VirtualThreadExecutor.
    Parameters:
      `namePrefix` - The name prefix for virtual threads

- ## Method Details

  - ### execute

    public void execute(Runnable command)

  - ### shutdown

    public void shutdown()

  - ### shutdownNow

    public List<Runnable> shutdownNow()

    The VirtualThreadExecutor does not track in-progress tasks so calling this method is equivalent to calling `shutdown()`.

  - ### isShutdown

    public boolean isShutdown()

  - ### isTerminated

    public boolean isTerminated()

    The VirtualThreadExecutor does not track in-progress tasks so calling this method is equivalent to calling `isShutdown()`.

  - ### awaitTermination

    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException

    The VirtualThreadExecutor does not track in-progress tasks so calling this method is effectively waiting for `shutdown()` to be called.

    Throws:
      `InterruptedException`