Which method is the least obtrusive for generating thread dumps in java?

前端 未结 2 1404
旧时难觅i
旧时难觅i 2020-12-10 18:47

I am aware of the following methods for generating thread dumps in java:

  • kill -3
  • jstack
  • JMX from inside the JVM
  • JMX remote
2条回答
  •  借酒劲吻你
    2020-12-10 19:25

    The most performant option is likely to be the use of the ThreadMXBean.dumpAllThreads() API rather than requesting a text thread dump written to disk: http://docs.oracle.com/javase/7/docs/api/java/lang/management/ThreadMXBean.html#dumpAllThreads(boolean,%20boolean)

    Of course, whether you can use that depends on whether you need a thread dump file, or just the data.

提交回复
热议问题