public class ThreadsCpuTimer extends NanoTimer
Modifier and Type | Field and Description |
---|---|
private ThreadsCpuMBean |
counter
Holds a counter for storing the measurement results
|
private java.util.Map<java.lang.Long,java.lang.Long> |
cpuStartTimes
Holds the initial points for CPU utilization measurements of threads
|
private long |
currentThreadId
Holds the current thread id used for this measurement
|
private java.lang.management.ThreadMXBean |
jmxBean
The management interface for the JVM thread system
|
private long[] |
threadIds
Holds the current threads at the time of this measurement
|
private boolean |
threadsMonitoringSupported
The flag that indicates that this JVM supports threads monitoring capabilities
|
private java.util.Map<java.lang.Long,java.lang.Long> |
userStartTimes
Holds the initial points for CPU utilization measurements of threads in a user mode
|
publish
enabled, enabler
Modifier | Constructor and Description |
---|---|
protected |
ThreadsCpuTimer(ThreadsCpuMBean counter,
java.util.function.LongConsumer publish)
Creates this thread CPU timer.
|
Modifier and Type | Method and Description |
---|---|
static ThreadsCpuTimer |
getInstance(ThreadsCpuMBean counter)
Create and register its instance.
|
void |
setEnabled(boolean enable)
Enables or disables thread CPU time measurement.
|
void |
start()
Start measurement operation.
|
void |
stop()
Stop operation and update counter
|
getInstance, timer
update
getEnabler, isEnabled, setEnabler
private final java.lang.management.ThreadMXBean jmxBean
private final boolean threadsMonitoringSupported
private final java.util.Map<java.lang.Long,java.lang.Long> cpuStartTimes
private final java.util.Map<java.lang.Long,java.lang.Long> userStartTimes
private long[] threadIds
private long currentThreadId
private final ThreadsCpuMBean counter
protected ThreadsCpuTimer(ThreadsCpuMBean counter, java.util.function.LongConsumer publish)
counter
- The threads CPU counter jmx interfacepublish
- The consumer of NanoTimer measurement resultspublic static ThreadsCpuTimer getInstance(ThreadsCpuMBean counter)
counter
- The instance of NanoCounterpublic void setEnabled(boolean enable)
setEnabled
in class AbstractCounter
enable
- The boolean value for enabling or disabling thread CPU time measurement.