Class VirtualThreadExecutor

java.lang.Object
java.util.concurrent.AbstractExecutorService
org.apache.tomcat.util.threads.VirtualThreadExecutor
All Implemented Interfaces:
Executor, ExecutorService

public class VirtualThreadExecutor extends AbstractExecutorService
An executor that uses a new virtual thread for each task.
  • 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