use ThreadCpu instead of ThreadCpuTime

This commit is contained in:
Doug MacEachern 2004-11-21 19:22:01 +00:00
parent 14f2e8811f
commit 2aeeb877c0
1 changed files with 3 additions and 3 deletions

View File

@ -5,12 +5,13 @@ import java.io.FileInputStream;
import net.hyperic.sigar.Sigar; import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarException; import net.hyperic.sigar.SigarException;
import net.hyperic.sigar.ThreadCpuTime; import net.hyperic.sigar.ThreadCpu;
//import java.lang.management.ManagementFactory; //import java.lang.management.ManagementFactory;
public class RunThreadCpu { public class RunThreadCpu {
static Sigar sigar = new Sigar(); static Sigar sigar = new Sigar();
static ThreadCpu cpu = new ThreadCpu();
static int iter = 5000; static int iter = 5000;
private static long toMillis(long nano) { private static long toMillis(long nano) {
@ -19,9 +20,8 @@ public class RunThreadCpu {
private static void printTimes(long start) { private static void printTimes(long start) {
//ThreadMXBean mx = ManagementFactory.getThreadMXBean(); //ThreadMXBean mx = ManagementFactory.getThreadMXBean();
ThreadCpuTime cpu = new ThreadCpuTime(sigar);
try { try {
cpu.getCurrent(); cpu.gather(sigar, 0);
} catch (SigarException e) { } catch (SigarException e) {
e.printStackTrace(); e.printStackTrace();
return; return;