Interface VirtualThreadSchedulerMXBean

All Superinterfaces:
PlatformManagedObject

public interface VirtualThreadSchedulerMXBean extends PlatformManagedObject
Management interface for the JDK's default virtual thread scheduler.

VirtualThreadSchedulerMXBean supports monitoring of the virtual thread scheduler's target parallelism and the platform threads used by the virtual thread scheduler as carrier threads. 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).

Since:
24
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns an estimate of the number of platform threads currently used by the scheduler as carriers for virtual threads; -1 if not known.
    int
    Returns the scheduler's target parallelism.
    long
    Returns an estimate of the number of virtual threads that are queued to the scheduler to start or continue execution; -1 if not known.
    int
    Returns the current number of platform threads in the scheduler's pool; -1 if not known.
    void
    setParallelism(int size)
    Sets the scheduler's target parallelism.

    Methods declared in interface java.lang.management.PlatformManagedObject

    getObjectName
  • Method Details

    • getParallelism

      int getParallelism()
      Returns the scheduler's target parallelism.
      Returns:
      the scheduler's target parallelism
      See Also:
    • setParallelism

      void setParallelism(int size)
      Sets the scheduler's target parallelism.
      Parameters:
      size - the target parallelism level
      Throws:
      IllegalArgumentException - if size is less than the minimum, or greater than the maximum, supported by the scheduler
      UnsupportedOperationException - if changing the target parallelism is not suppored by the scheduler
      See Also:
    • getThreadCount

      int getThreadCount()
      Returns the current number of platform threads in the scheduler's pool; -1 if not known.
      API Note:
      The number of threads may be greater than the scheduler's target parallelism.
      Returns:
      the current number of platform threads in the scheduler's pool; -1 if not known
    • getCarrierThreadCount

      int getCarrierThreadCount()
      Returns an estimate of the number of platform threads currently used by the scheduler as carriers for virtual threads; -1 if not known.
      Returns:
      an estimate of the number of platform threads currently used by the scheduler as carriers for virtual threads; -1 if not known
    • getQueuedVirtualThreadCount

      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.
      Returns:
      an estimate of the number of virtual threads that are queued to the scheduler to start or continue execution; -1 if not known