PlatformManagedObjectpublic interface VirtualThreadSchedulerMXBean extends PlatformManagedObject
VirtualThreadSchedulerMXBean supports monitoring of the virtual thread scheduler's target parallelism, the platform threads used by the scheduler, and the number of virtual threads queued to the scheduler. It also supports dynamically changing the scheduler's target parallelism.
The management interface is registered with the platform MBeanServer. The ObjectName that uniquely identifies the management interface within the MBeanServer is: "jdk.management:type=VirtualThreadScheduler".
Direct access to the MXBean interface can be obtained with ManagementFactory.getPlatformMXBean(Class).
| Modifier and Type | Method | Description |
|---|---|---|
int |
getMountedVirtualThreadCount() |
Returns an estimate of the number of virtual threads that are currently mounted by the scheduler; -1 if not known. |
int |
getParallelism() |
Returns the scheduler's target parallelism. |
int |
getPoolSize() |
Returns the current number of platform threads that the scheduler has started but have not terminated; -1 if not known. |
long |
getQueuedVirtualThreadCount() |
Returns an estimate of the number of virtual threads that are queued to the scheduler to start or continue execution; -1 if not known. |
void |
setParallelism |
Sets the scheduler's target parallelism. |
getObjectName
int getParallelism()
void setParallelism(int size)
Increasing the target parallelism allows the scheduler to use more platform threads to carry virtual threads if required. Decreasing the target parallelism reduces the number of threads that the scheduler may use to carry virtual threads.
ForkJoinPool. Target parallelism defaults to the number of available processors. The minimum target parallelism is 1, the maximum target parallelism is 32767.size - the target parallelism levelIllegalArgumentException - if size is less than the minimum, or greater than the maximum, supported by the schedulerUnsupportedOperationException - if changing the target parallelism is not suppored by the schedulerint getPoolSize()
-1 if not known. The count includes the platform threads that are currently carrying virtual threads and the platform threads that are not currently carrying virtual threads. The thread count may be greater than the scheduler's target parallelism.
ForkJoinPool. The pool size is the number of worker threads.-1 if not knownint getMountedVirtualThreadCount()
-1 if not known. The number of mounted virtual threads is equal to the number of platform threads carrying virtual threads.
-1 if not knownlong getQueuedVirtualThreadCount()
-1 if not known.-1 if not known
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/jdk.management/jdk/management/VirtualThreadSchedulerMXBean.html