// time_cpu.java check measuring CPU process time import java.lang.management.ManagementFactory; import java.lang.management.ThreadMXBean; public class time_cpu { double now; double next; time_cpu() { System.out.println("time_cpu starting"); System.out.println("Should be CPU time, 5 second intervals"); ThreadMXBean tb = ManagementFactory.getThreadMXBean(); now = tb.getCurrentThreadCpuTime()/1.0E9; next = now+5.0; for(int i=0; i<90;) { now = tb.getCurrentThreadCpuTime()/1.0E9; if(now >= next) { System.out.println(i); i=i+5; next=next+5.0; } } } // end time_cpu constructor static public void main(String[] args) { new time_cpu(); } // end main } // end class time_cpu