Efficient way of getting thread CPU time using JMX
问题 I'm currently getting the total thread CPU time using JMX in the following manner: private long calculateTotalThreadCpuTime(ThreadMXBean thread) { long totalTime = 0l; for (ThreadInfo threadInfo : thread.dumpAllThreads(false, false)) totalTime += thread.getThreadCpuTime(threadInfo.getThreadId()); return totalTime; } As the ThreadMXBean is actually a remote proxy, performance is dreadful , in the order of magnitude of seconds for this actual method call. Is there a faster way of doing this?