Ejemplo n.º 1
0
 public override long cpuTimeNanos(long threadId)
 {
     if (!threadMXBean.ThreadCpuTimeSupported)
     {
         return(-1);
     }
     if (!threadMXBean.ThreadCpuTimeEnabled)
     {
         threadMXBean.ThreadCpuTimeEnabled = true;
     }
     return(threadMXBean.getThreadCpuTime(threadId));
 }
Ejemplo n.º 2
0
        /// <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));
            }
        }