Utility class to use to query the runtime for virtual thread support, and, if virtual threads are supported, to start virtual threads.
areSupported(), getVirtualThreadsExecutor(Executor), isVirtualThread()
| Modifier and Type | Class and Description |
|---|---|
| public static interface | VirtualThreads.Configurable
Implementations of this interface can be configured to use virtual threads. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Executor | |
| private static final Method | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | |
| public static void | executeOnVirtualThread(Runnable
the task to execute in a virtual thread task)
Deprecated
for removal. use
getVirtualThreadsExecutor(Executor) instead
Starts a virtual thread to execute the given task, or throws
|
| public static Executor | Returns: a default virtual thread per taskExecutorGet a default virtual thread per task |
| private static Method | |
| public static Executor | Returns: a virtual threadsExecutor obtained from the given Executorthe executor)Executor to obtain a virtual threads Executor from
|
| public static boolean | Returns: whether the given executor implementsConfigurable
and it has been configured to use virtual threadsthe Executor to test executor)Tests whether the given executor implements |
| public static boolean | |
| private static Method | |
| private static Executor | |
| private static void |
| executor | back to summary |
|---|---|
| private static final Executor executor | |
| isVirtualThread | back to summary |
|---|---|
| private static final Method isVirtualThread | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| VirtualThreads | back to summary |
|---|---|
| private VirtualThreads() | |
| areSupported | back to summary |
|---|---|
public static boolean areSupported()
| |
| executeOnVirtualThread | back to summary |
|---|---|
| public static void executeOnVirtualThread(Runnable task)
Starts a virtual thread to execute the given task, or throws
| |
| getDefaultVirtualThreadsExecutor | back to summary |
|---|---|
| public static Executor getDefaultVirtualThreadsExecutor() Get a default virtual thread per task
| |
| getIsVirtualThreadMethod | back to summary |
|---|---|
| private static Method getIsVirtualThreadMethod() | |
| getVirtualThreadsExecutor | back to summary |
|---|---|
| public static Executor getVirtualThreadsExecutor(Executor executor) | |
| isUseVirtualThreads | back to summary |
|---|---|
| public static boolean isUseVirtualThreads(Executor executor) Tests whether the given executor implements
| |
| isVirtualThread | back to summary |
|---|---|
public static boolean isVirtualThread()
| |
| probeIsVirtualThread | back to summary |
|---|---|
| private static Method probeIsVirtualThread() | |
| probeVirtualThreadExecutor | back to summary |
|---|---|
| private static Executor probeVirtualThreadExecutor() | |
| warn | back to summary |
|---|---|
| private static void warn() | |
Implementations of this interface can be configured to use virtual threads.
Whether virtual threads are actually used depends on whether the runtime
supports virtual threads and, if the runtime supports them, whether they are
configured to be used via setVirtualThreadsExecutor(Executor).
| Modifier and Type | Method and Description |
|---|---|
| public default Executor | |
| public default boolean | Returns: whether to use virtual threads
Deprecated
for removal. use
getVirtualThreadsExecutor() instead
|
| public default void | setUseVirtualThreads(boolean
whether to use virtual threads useVirtualThreads)
Deprecated
for removal. use
setVirtualThreadsExecutor(Executor) instead
|
| public default void |
| getVirtualThreadsExecutor | back to summary |
|---|---|
public default Executor getVirtualThreadsExecutor()
| |
| isUseVirtualThreads | back to summary |
|---|---|
public default boolean isUseVirtualThreads()
| |
| setUseVirtualThreads | back to summary |
|---|---|
public default void setUseVirtualThreads(boolean useVirtualThreads)
| |
| setVirtualThreadsExecutor | back to summary |
|---|---|
public default void setVirtualThreadsExecutor(Executor executor)
| |