Package oshi.software.common
Class AbstractOSThread
java.lang.Object
oshi.software.common.AbstractOSThread
- All Implemented Interfaces:
OSThread
- Direct Known Subclasses:
AixOSThread,FreeBsdOSThread,LinuxOSThread,MacOSThread,SolarisOSThread,WindowsOSThread
public abstract class AbstractOSThread extends java.lang.Object implements OSThread
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOSThread(int processId) -
Method Summary
Modifier and Type Method Description longgetContextSwitches()A snapshot of the context switches the thread has done.longgetMajorFaults()The number of major (hard) faults the thread has made which have required loading a memory page from disk.longgetMinorFaults()The number of minor (soft) faults the thread has made which have not required loading a memory page from disk.java.lang.StringgetName()The name of the thread.intgetOwningProcessId()The owning process of this thread.longgetStartMemoryAddress()The memory address above which this thread can run.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.java.lang.StringtoString()booleanupdateAttributes()Attempts to updates process attributes.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface oshi.software.os.OSThread
getKernelTime, getPriority, getStartTime, getState, getThreadId, getUpTime, getUserTime
-
Constructor Details
-
AbstractOSThread
protected AbstractOSThread(int processId)
-
-
Method Details
-
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.
-
getThreadCpuLoadBetweenTicks
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.
-
getName
public java.lang.String getName()Description copied from interface:OSThreadThe name of the thread. Presence of a name is operating-system dependent and may include information (such as an index of running threads) that changes during execution. -
getStartMemoryAddress
public long getStartMemoryAddress()Description copied from interface:OSThreadThe memory address above which this thread can run.- Specified by:
getStartMemoryAddressin interfaceOSThread- Returns:
- The start address.
-
getContextSwitches
public long getContextSwitches()Description copied from interface:OSThreadA snapshot of the context switches the thread has done. Since the context switches could be voluntary and non-voluntary, this gives the sum of both.- Specified by:
getContextSwitchesin interfaceOSThread- Returns:
- sum of both voluntary and involuntary context switches.
-
getMinorFaults
public long getMinorFaults()Description copied from interface:OSThreadThe number of minor (soft) faults the thread has made which have not required loading a memory page from disk. Sometimes called reclaims. Linux only.- Specified by:
getMinorFaultsin interfaceOSThread- Returns:
- minor faults.
-
getMajorFaults
public long getMajorFaults()Description copied from interface:OSThreadThe number of major (hard) faults the thread has made which have required loading a memory page from disk. Linux only.- Specified by:
getMajorFaultsin interfaceOSThread- Returns:
- major faults.
-
updateAttributes
public boolean updateAttributes()Description copied from interface:OSThreadAttempts to updates process attributes. Returns false if the update fails, which will occur if the process no longer exists. Not implemented for macOS, as thread ID is simply an index and not unique.- Specified by:
updateAttributesin interfaceOSThread- Returns:
trueif the update was successful, false if the update failed. In addition, on a failed update the thread state will be changed toOSProcess.State.INVALID.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-