Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Thread dumps

Traditional thread dumps (jstack, jcmd Thread.print) do not include virtual threads. If the thread dump is taken when a virtual thread is mounted then its stack will be shown in the stack trace of its carrier thread. No information about unmounted virtual threads will be included.

The current prototype has an alternative thread dump that includes all platform threads plus all virtual threads started with a thread Executor (Executors.newVirtualThreadExector or Executors.newThreadExector). The thread dump is generated to a file in plain text or JSON format. The thread dump can be generated programmatically with ThreadMXBean or with the jcmd tool. The jcmd tool can be used to generate the thread dump, optionally to a file:

    jcmd <pid> JavaThread.dump
jcmd <pid> JavaThread.dump json
jcmd <pid> JavaThread.dump text /tmp/threads.txt
jcmd <pid> <pid> ThreadJavaThread.dump_to_ json_file <file> /tmp/threads.json

The JSON file output has two arrays. There is one array for the threads that includes the identifier, name, and stack trace of each thread. The second array has the thread executors and the identifiers of all threads started by the executor.

...