`Monitor cpu usage per thread in java?

后端 未结 6 2052
日久生厌
日久生厌 2020-12-07 21:15

I would like to ask whether there is some simple way to determine cpu usage per thread in java. Thanks

6条回答
  •  温柔的废话
    2020-12-07 21:34

    Though this is platform dependent, I believe what you're looking for is the ThreadMXBean: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/ThreadMXBean.html . You can use the getThreadUserTime method, for example, to get what you need. To check if your platform supports CPU measurement, you can call isThreadCpuTimeSupported() .

提交回复
热议问题