List All Virtual Threads in a JVM
Michal Domagala
outsider404 at gmail.com
Wed Oct 23 12:14:16 UTC 2024
In my opinion you should not treat VirtualThread differently than any other
class, for example ArrayList. Like ArrayList, JVM may have hundreds
of thousands of VirtualThread's and in every second thousands can be
created and thousands can be garbage collected.
In my opinion you cannot expect that JVM will give you all virtual threads.
(Compared to platform threads, platform thread count is usually limited to
hundreds). Like for ArrayList, you can take heap dump
Anyway, JVM keeps all virtual threads
in jdk.internal.vm.ThreadContainers.RootContainer.TrackingRootContainer#VTHREADS.
But I hope it is dead end and will be abandoned
śr., 23 paź 2024 o 13:47 Nathan Reynolds <numeralnathan at gmail.com>
napisał(a):
> How do I list all the virtual threads in a JVM?
> ThreadMXBean.dumpAllThreads(), ThreadMXBean.getAllThreadIds(),
> ThreadGroup.enumerate(), and Thread.getAllStackTraces() do not return
> virtual threads. See my question at
> https://stackoverflow.com/questions/79110874/list-the-virtual-threads-in-java
> .
>
> I can see how these APIs would not scale for virtual threads. What are
> the thoughts for an API to list all the virtual threads? For an in-process
> API, would an API that returns Stream<Thread> scale? I am not sure how an
> MXBean API can stream Threads to make it scale.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20241023/2c3fa7f2/attachment-0001.htm>
More information about the loom-dev
mailing list