diff --git a/bindings/java/src/net/hyperic/sigar/ThreadCpuTime.java b/bindings/java/src/net/hyperic/sigar/ThreadCpuTime.java new file mode 100644 index 00000000..8e388d40 --- /dev/null +++ b/bindings/java/src/net/hyperic/sigar/ThreadCpuTime.java @@ -0,0 +1,33 @@ +package net.hyperic.sigar; + +public class ThreadCpuTime extends ThreadCpu { + private ThreadCpu diff = null; + private Sigar sigar; + + public ThreadCpuTime(Sigar sigar) { + super(); + this.sigar = sigar; + } + + public void getCurrent() throws SigarException { + this.nativeGet(this.sigar, 0); + } + + public ThreadCpu getDiff() throws SigarException { + long startTotal = this.total; + long startUser = this.user; + long startSys = this.sys; + + if (this.diff == null) { + this.diff = new ThreadCpu(); + } + + getCurrent(); + + this.diff.total = this.total - startTotal; + this.diff.user = this.user - startUser; + this.diff.sys = this.sys - startSys; + + return this.diff; + } +}