public override long cpuTimeNanos(long threadId) { if (!threadMXBean.ThreadCpuTimeSupported) { return(-1); } if (!threadMXBean.ThreadCpuTimeEnabled) { threadMXBean.ThreadCpuTimeEnabled = true; } return(threadMXBean.getThreadCpuTime(threadId)); }
/// <summary>Get CPU time in nanoseconds. </summary> static public long getCpuTime(long id) { ThreadMXBean bean = ManagementFactory.getThreadMXBean(); if (!bean.isThreadCpuTimeSupported()) { return(0L); } else { return(bean.getThreadCpuTime(id)); } }