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

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

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