Class VirtualThreadExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
org.apache.tomcat.util.threads.VirtualThreadExecutor
- All Implemented Interfaces:
AutoCloseable, Executor, ExecutorService
An executor that uses a new virtual thread for each task.
-
Constructor Summary
ConstructorsConstructorDescriptionVirtualThreadExecutor(String namePrefix) Constructs a new VirtualThreadExecutor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) voidbooleanbooleanvoidshutdown()Methods inherited from class AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ExecutorService
close
-
Constructor Details
-
VirtualThreadExecutor
Constructs a new VirtualThreadExecutor.- Parameters:
namePrefix- The name prefix for virtual threads
-
-
Method Details
-
execute
-
shutdown
public void shutdown() -
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
The VirtualThreadExecutor does not track in-progress tasks so calling this method is effectively waiting for
shutdown()to be called.- Throws:
InterruptedException
-