Get user time in nanoseconds via Management bean - Java java.lang.management

Java examples for java.lang.management:MemoryMXBean

Description

Get user time in nanoseconds via Management bean

Demo Code


//package com.java2s;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;

public class Main {
    /** Get user time in nanoseconds. */
    public static long getUserTime() {
        ThreadMXBean bean = ManagementFactory.getThreadMXBean();
        return bean.isCurrentThreadCpuTimeSupported() ? bean
                .getCurrentThreadUserTime() : 0L;
    }/*from  www . ja v a 2 s . c om*/
}

Related Tutorials