Package oshi.software.common
Class AbstractOSThread
- java.lang.Object
-
- oshi.software.common.AbstractOSThread
-
- All Implemented Interfaces:
OSThread
- Direct Known Subclasses:
AixOSThread,FreeBsdOSThread,LinuxOSThread,MacOSThread,OpenBsdOSThread,SolarisOSThread,WindowsOSThread
@ThreadSafe public abstract class AbstractOSThread extends java.lang.Object implements OSThread
Common methods for OSThread implementation
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface oshi.software.os.OSThread
OSThread.ThreadFiltering
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Supplier<java.lang.Double>cumulativeCpuLoadprivate intowningProcessId
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOSThread(int processId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetOwningProcessId()The owning process of this thread.doublegetThreadCpuLoadBetweenTicks(OSThread priorSnapshot)Gets CPU usage of this thread since a previous snapshot of the same thread, provided as a parameter.doublegetThreadCpuLoadCumulative()Gets cumulative CPU usage of this thread.private doublequeryCumulativeCpuLoad()java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface oshi.software.os.OSThread
getContextSwitches, getKernelTime, getMajorFaults, getMinorFaults, getName, getPriority, getStartMemoryAddress, getStartTime, getState, getThreadId, getUpTime, getUserTime, updateAttributes
-
-
-
-
Method Detail
-
getOwningProcessId
public int getOwningProcessId()
Description copied from interface:OSThreadThe owning process of this thread. For single-threaded processes, the owning process ID may be the same as the thread's ID.- Specified by:
getOwningProcessIdin interfaceOSThread- Returns:
- The owning process of this thread.
-
getThreadCpuLoadCumulative
public double getThreadCpuLoadCumulative()
Description copied from interface:OSThreadGets cumulative CPU usage of this thread.- Specified by:
getThreadCpuLoadCumulativein interfaceOSThread- Returns:
- The proportion of up time that the thread was executing in kernel or user mode.
-
queryCumulativeCpuLoad
private double queryCumulativeCpuLoad()
-
getThreadCpuLoadBetweenTicks
public double getThreadCpuLoadBetweenTicks(OSThread priorSnapshot)
Description copied from interface:OSThreadGets CPU usage of this thread since a previous snapshot of the same thread, provided as a parameter.- Specified by:
getThreadCpuLoadBetweenTicksin interfaceOSThread- Parameters:
priorSnapshot- AnOSThreadobject containing statistics for this same thread collected at a prior point in time. May be null.- Returns:
- If the prior snapshot is for the same thread at a prior point in time, the proportion of elapsed up time between the current thread snapshot and the previous one that the thread was executing in kernel or user mode. Returns cumulative load otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-