Efficient way of getting thread CPU time using JMX

后端 未结 5 1013
后悔当初
后悔当初 2020-12-31 22:19

I\'m currently getting the total thread CPU time using JMX in the following manner:

private long calculateTotalThreadCpuTime(ThreadMXBean thread) {

    long         


        
5条回答
  •  情歌与酒
    2020-12-31 23:15

    Optimisations:

    • invoke getThreadCPUTime inside a thread pool, since it seems to be network-bound;
    • whenever a thread is found to be in Thread.STATE.TERMINATED, keep its name in a Map and skip querying the next time.

提交回复
热议问题