...
JDI VirtualThreads.allThreads (
...
and JDWP VirtualMachine/AllThreads
...
) continue to enumerate all platform threads.
Thread groups
Virtual threads are not active members of a thread group.
JDI ThreadGroupReference::threads
...
(and JDWP ThreadGroupReference/Children
...
Thread start/end events
New JDI ThreadStartRequest/ThreadEndRequest removeVirtualThreadFilter method to virtual events for virtual threads, filter is opt-out
) continue to enumerate all platform threads in the group.
ThreadStartRequest/ThreadDeathRequest define a new method removeVirtualThreadFilter that can be used to remove the filtering of
...
thread start/end events for virtual threads
...
. This may be changed so that JDI clients opt-out rather than opt-in
...
Test if a thread is a virtual thread
New JDI ThreadReference::isVirtual
New JDWP ThreadReference/IsVirtual
for these events.
Not Supported
The following are current not supported
...
for virtual threads:
- JDI ThreadReference::stop / JDWP ThreadReference/Stop
- JDI ThreadReference::interrupt / JDWP ThreadReference/Interrupt
...
Debuggers and tools using the Java Debug Interface API observe the following differences:
- com.sun.jdi.VirtualMachine::allThreads enumerates platform threads only, the list does not include mirrors for virtual threads.
- Virtual threads are not live threads in a thread group so ThreadGroupReference::threads only lists platform threads.
- ThreadStartRequest/ThreadDeathRequest request notifications of thread start/termination of platform threads by default. Tools have to opt-in to get start/death events for virtual threads (by invoking the removeVirtualThreadFilter method on the event request.
...
JDWP agent options (temporary)
Option Name and Value Description Default
--------------------- ----------- -------
trackvthreads=some|all track some or all vthreads some
enumeratevthreads=y|n thread lists include vthreads y
fakevthreadstartevent=y|n send fake start event when needed y
enumeratevthreads
control whether or not vthreads are included inVM.allThreads
andThreadGroupReference.children
.trackvthreads
determines what vthreads will be returned ifenumeratevthreads=y
, so it doesn’t carry any meaning to the user ifenumeratevthreads=n
, but will still impact with the debug agent does internallyfakevthreadstartevent
is independent of the two others. Ify
, then before sending an event, send a fake THREAD_START event for if the debugger hasn’t already been notified about the vthread the event occurred on. Intellij needs this. Note currently there is a bug, and iftrackvthreads=all
, no fake THREAD_START will ever be sent. This is only an issue if the debug agent is started after some vthreads have been created (a mode I haven’t even tested yet, and I don’t think is commonly used). (edited)
...