How to get the number of threads in a Java process

后端 未结 9 796
无人及你
无人及你 2020-12-07 19:49

How can I see the number of threads in a Java process?

9条回答
  •  鱼传尺愫
    2020-12-07 20:36

    There is a static method on the Thread Class that will return the number of active threads controlled by the JVM:

    Thread.activeCount()

    Returns the number of active threads in the current thread's thread group.

    Additionally, external debuggers should list all active threads (and allow you to suspend any number of them) if you wish to monitor them in real-time.

提交回复
热议问题