| Modifier and Type | Field and Description |
|---|---|
| private static final ThreadLocal |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | Returns: true.Checks if the current Thread has been interrupted, without clearing the flag; if interrupted,
an |
| private static boolean | Returns: true if so.Checks if the current platform Thread is treated as a virtual one. |
| public static boolean | Returns: true if so.Checks if the current |
| public static boolean | Returns: true if so.Checks if virtual threads are considered to be supported (and therefore if special support should be enabled). |
| public static ExecutorService | Returns: The new executor service.Returns a new "virtual thread per task executor". |
| public static void | runOnSystemThread(Runnable
The operation to run. op)Ensures that the given operation is being executed on a system thread. |
| public static void | setTreatAsVirtualThread(boolean
true to enable treatment of a platform thread as a virtual thread.Marks the current platform |
| public static Thread | Returns: The thread.If virtual, Runnable true, try to start a virtual Thread instead of a platform Thread (or
at least pretend it's a virtual thread if they're not supported natively); if
false, a "daemon" platform thread is started.The runnable. run)Starts a new daemon thread. |
| TREAT_AS_VIRTUAL_THREAD | back to summary |
|---|---|
| private static final ThreadLocal<Boolean> TREAT_AS_VIRTUAL_THREAD | |
| ThreadUtil | back to summary |
|---|---|
| private ThreadUtil() | |
| checkNotInterruptedOrThrow | back to summary |
|---|---|
| public static boolean checkNotInterruptedOrThrow() throws InterruptedIOException Checks if the current Thread has been interrupted, without clearing the flag; if interrupted,
an
| |
| isTreatAsVirtualThread | back to summary |
|---|---|
| private static boolean isTreatAsVirtualThread() Checks if the current platform Thread is treated as a virtual one.
| |
| isVirtualThread | back to summary |
|---|---|
| public static boolean isVirtualThread() Checks if the current
| |
| isVirtualThreadSupported | back to summary |
|---|---|
| public static boolean isVirtualThreadSupported() Checks if virtual threads are considered to be supported (and therefore if special support should be enabled).
| |
| newVirtualThreadPerTaskExecutor | back to summary |
|---|---|
| public static ExecutorService newVirtualThreadPerTaskExecutor() Returns a new "virtual thread per task executor". If virtual threads are not supported by this JVM, a new platform thread are created for each task, and such threads are marked to be treated as virtual threads.
| |
| runOnSystemThread | back to summary |
|---|---|
| public static void runOnSystemThread(Runnable op) throws InterruptedException Ensures that the given operation is being executed on a system thread. If the current thread is
a virtual thread, the operation is executed synchronously via
| |
| setTreatAsVirtualThread | back to summary |
|---|---|
| public static void setTreatAsVirtualThread(boolean b) Marks the current platform
| |
| startNewDaemonThread | back to summary |
|---|---|
| public static Thread startNewDaemonThread(boolean virtual, Runnable run) Starts a new daemon thread. | |