java.lang.Object
org.eclipse.jetty.util.VirtualThreads
Utility class to use to query the runtime for virtual thread support, and, if virtual threads are supported, to start virtual threads.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceImplementations of this interface can be configured to use virtual threads. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic voidStarts a virtual thread to execute the given task, or throwsUnsupportedOperationExceptionif virtual threads are not supported.static booleanisUseVirtualThreads(Executor executor) Tests whether the given executor implementsVirtualThreads.Configurableand it has been configured to use virtual threads.static boolean
-
Method Details
-
areSupported
public static boolean areSupported()- Returns:
- whether the runtime supports virtual threads
-
executeOnVirtualThread
Starts a virtual thread to execute the given task, or throws
UnsupportedOperationExceptionif virtual threads are not supported.- Parameters:
task- the task to execute in a virtual thread- See Also:
-
isVirtualThread
public static boolean isVirtualThread()- Returns:
- whether the current thread is a virtual thread
-
isUseVirtualThreads
Tests whether the given executor implements
VirtualThreads.Configurableand it has been configured to use virtual threads.- Parameters:
executor- the Executor to test- Returns:
- whether the given executor implements
VirtualThreads.Configurableand it has been configured to use virtual threads
-