`Monitor cpu usage per thread in java?

后端 未结 6 2056
日久生厌
日久生厌 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:24

    Indeed the object ThreadMXBean provides the functionality you need (however it might not be implemented on all virtual machines).

    In JDK 1.5 there was a demo program doing exactly what you need. It was in the folder demo/management and it was called JTop.java

    Unfortnately, it's not there in Java6. Maybe you can find at with google or download JDK5.

提交回复
热议问题