ThreadInfo contains the information
about a thread including:
Object.wait method,
orLockSupport.park call.thread contention monitoring
was enabled. Some Java virtual machine implementation
may not support this. The
ThreadMXBean#isThreadContentionMonitoringSupported()
method can be used to determine if a Java virtual machine
supports this.This thread information class is designed for use in monitoring of the system, not for synchronization control.
ThreadInfo is mapped to a CompositeData
with attributes as specified in
the from method.
ThreadMXBean#getThreadInfo, ThreadMXBean#dumpAllThreads
| Modifier and Type | Field and Description |
|---|---|
| private long | |
| private long | |
| private boolean | |
| private static MonitorInfo[] | |
| private static LockInfo[] | |
| private boolean | |
| private LockInfo | |
| private MonitorInfo[] | |
| private LockInfo[] | |
| private String | |
| private long | |
| private String | |
| private static final int | |
| private static final StackTraceElement[] | |
| private int | |
| private StackTraceElement[] | |
| private boolean | |
| private long | |
| private String | |
| private Thread. | |
| private long | |
| private long |
| Access | Constructor and Description |
|---|---|
| private | ThreadInfo(Thread
Thread t, int Thread state state, Object Object on which the thread is blocked lockObj, Thread the thread holding the lock lockOwner, long Number of times blocked to enter a lock blockedCount, long Approx time blocked to enter a lock blockedTime, long Number of times waited on a lock waitedCount, long Approx time waited on a lock waitedTime, StackTraceElement[] Thread stack trace stackTrace)Constructor of ThreadInfo created by the JVM |
| private | ThreadInfo(Thread
Thread t, int Thread state state, Object Object on which the thread is blocked lockObj, Thread the thread holding the lock lockOwner, long Number of times blocked to enter a lock blockedCount, long Approx time blocked to enter a lock blockedTime, long Number of times waited on a lock waitedCount, long Approx time waited on a lock waitedTime, StackTraceElement[] Thread stack trace stackTrace, Object[] List of locked monitors monitors, int[] List of stack depths stackDepths, Object[] List of locked synchronizers synchronizers)Constructor of ThreadInfo created by the JVM
for |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static ThreadInfo | Returns: aThreadInfo object represented
by cd if cd is not null;
null otherwise.CompositeData representing a ThreadInfoReturns a |
| public long | Returns: the total number of times that the thread entered theBLOCKED state.Returns the total number of times that
the thread associated with this |
| public long | Returns: the approximate accumulated elapsed time in milliseconds that a thread entered theBLOCKED state;
-1 if thread contention monitoring is disabled.Returns the approximate accumulated elapsed time (in milliseconds)
that the thread associated with this |
| public MonitorInfo[] | Returns: an array ofMonitorInfo objects representing
the object monitors locked by the thread.Returns an array of |
| public LockInfo[] | Returns: an array ofLockInfo objects representing
the ownable synchronizers locked by the thread.Returns an array of |
| public LockInfo | Returns: LockInfo of an object for which the thread
is blocked waiting if any; null otherwise.Returns the |
| public String | Returns: the string representation of the object on which the thread is blocked if any;null otherwise.Returns the |
| public long | Returns: the thread ID of the owner thread of the object this thread is blocked on;-1 if this thread is not blocked
or if the object is not owned by any thread.Returns the ID of the thread which owns the object
for which the thread associated with this |
| public String | Returns: the name of the thread that owns the object this thread is blocked on;null if this thread is not blocked
or if the object is not owned by any thread.Returns the name of the thread which owns the object
for which the thread associated with this |
| public int | Returns: The priority of the thread associated with thisThreadInfo.Returns the thread priority of the
thread associated with this |
| public StackTraceElement[] | Returns: an array ofStackTraceElement objects of the thread.Returns the stack trace of the thread
associated with this |
| public long | Returns: the ID of the associated thread.Returns the ID of the thread associated with this |
| public String | Returns: the name of the associated thread.Returns the name of the thread associated with this |
| public Thread. | Returns: Thread.State of the associated thread.Returns the state of the thread associated with this |
| public long | Returns: the total number of times that the thread was in theWAITING or TIMED_WAITING state.Returns the total number of times that
the thread associated with this |
| public long | Returns: the approximate accumulated elapsed time in milliseconds that a thread has been in theWAITING or
TIMED_WAITING state;
-1 if thread contention monitoring is disabled.Returns the approximate accumulated elapsed time (in milliseconds)
that the thread associated with this |
| private void | initialize(Thread
Thread t, int Thread state state, Object Object on which the thread is blocked lockObj, Thread the thread holding the lock lockOwner, long Number of times blocked to enter a lock blockedCount, long Approx time blocked to enter a lock blockedTime, long Number of times waited on a lock waitedCount, long Approx time waited on a lock waitedTime, StackTraceElement[] Thread stack trace stackTrace, MonitorInfo[] List of locked monitors lockedMonitors, LockInfo[] List of locked synchronizers lockedSynchronizers)Initialize ThreadInfo object |
| public boolean | Returns: true if the thread is a daemon thread,
false otherwise.Tests if the thread associated with this |
| public boolean | Returns: true if the thread is executing native code;
false otherwise.Tests if the thread associated with this |
| public boolean | Returns: true if the thread is suspended;
false otherwise.Tests if the thread associated with this |
| public String | Returns: a string representation of this thread info.Overrides java. Returns a string representation of this thread info. |
| blockedCount | back to summary |
|---|---|
| private long blockedCount | |
| blockedTime | back to summary |
|---|---|
| private long blockedTime | |
| daemon | back to summary |
|---|---|
| private boolean daemon | |
| EMPTY_MONITORS | back to summary |
|---|---|
| private static MonitorInfo[] EMPTY_MONITORS | |
| EMPTY_SYNCS | back to summary |
|---|---|
| private static LockInfo[] EMPTY_SYNCS | |
| inNative | back to summary |
|---|---|
| private boolean inNative | |
| lock | back to summary |
|---|---|
| private LockInfo lock | |
| lockedMonitors | back to summary |
|---|---|
| private MonitorInfo[] lockedMonitors | |
| lockedSynchronizers | back to summary |
|---|---|
| private LockInfo[] lockedSynchronizers | |
| lockName | back to summary |
|---|---|
| private String lockName | |
| lockOwnerId | back to summary |
|---|---|
| private long lockOwnerId | |
| lockOwnerName | back to summary |
|---|---|
| private String lockOwnerName | |
| MAX_FRAMES | back to summary |
|---|---|
| private static final int MAX_FRAMES | |
| NO_STACK_TRACE | back to summary |
|---|---|
| private static final StackTraceElement[] NO_STACK_TRACE | |
| priority | back to summary |
|---|---|
| private int priority | |
| stackTrace | back to summary |
|---|---|
| private StackTraceElement[] stackTrace | |
| suspended | back to summary |
|---|---|
| private boolean suspended | |
| threadId | back to summary |
|---|---|
| private long threadId | |
| threadName | back to summary |
|---|---|
| private String threadName | |
| threadState | back to summary |
|---|---|
| private Thread. | |
| waitedCount | back to summary |
|---|---|
| private long waitedCount | |
| waitedTime | back to summary |
|---|---|
| private long waitedTime | |
| ThreadInfo | back to summary |
|---|---|
| private ThreadInfo(Thread t, int state, Object lockObj, Thread lockOwner, long blockedCount, long blockedTime, long waitedCount, long waitedTime, StackTraceElement[] stackTrace) Constructor of ThreadInfo created by the JVM
| |
| ThreadInfo | back to summary |
|---|---|
| private ThreadInfo(Thread t, int state, Object lockObj, Thread lockOwner, long blockedCount, long blockedTime, long waitedCount, long waitedTime, StackTraceElement[] stackTrace, Object[] monitors, int[] stackDepths, Object[] synchronizers) Constructor of ThreadInfo created by the JVM
for
| |
| ThreadInfo | back to summary |
|---|---|
| private ThreadInfo(CompositeData cd) | |
| from | back to summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public static ThreadInfo from(CompositeData cd) Returns a
A
CompositeData representing
StackTraceElement of version N must contain
all of the attributes defined in version ≤ N
unless specified otherwise.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getBlockedCount | back to summary |
|---|---|
| public long getBlockedCount() Returns the total number of times that
the thread associated with this
| |
| getBlockedTime | back to summary |
|---|---|
| public long getBlockedTime() Returns the approximate accumulated elapsed time (in milliseconds)
that the thread associated with this The Java virtual machine may measure the time with a high resolution timer. This statistic is reset when the thread contention monitoring is re-enabled.
| |
| getLockedMonitors | back to summary |
|---|---|
| public MonitorInfo[] getLockedMonitors() Returns an array of
| |
| getLockedSynchronizers | back to summary |
|---|---|
| public LockInfo[] getLockedSynchronizers() Returns an array of
| |
| getLockInfo | back to summary |
|---|---|
| public LockInfo getLockInfo() Returns the
This method returns
| |
| getLockName | back to summary |
|---|---|
| public String getLockName() Returns the getLockInfo().toString() This method will return
| |
| getLockOwnerId | back to summary |
|---|---|
| public long getLockOwnerId() Returns the ID of the thread which owns the object
for which the thread associated with this
| |
| getLockOwnerName | back to summary |
|---|---|
| public String getLockOwnerName() Returns the name of the thread which owns the object
for which the thread associated with this
| |
| getPriority | back to summary |
|---|---|
| public int getPriority() Returns the thread priority of the
thread associated with this
| |
| getStackTrace | back to summary |
|---|---|
| public StackTraceElement[] getStackTrace() Returns the stack trace of the thread
associated with this Some Java virtual machines may, under some circumstances, omit one
or more stack frames from the stack trace. In the extreme case,
a virtual machine that has no stack trace information concerning
the thread associated with this
| |
| getThreadId | back to summary |
|---|---|
| public long getThreadId() Returns the ID of the thread associated with this
| |
| getThreadName | back to summary |
|---|---|
| public String getThreadName() Returns the name of the thread associated with this
| |
| getThreadState | back to summary |
|---|---|
| public Thread. Returns the state of the thread associated with this | |
| getWaitedCount | back to summary |
|---|---|
| public long getWaitedCount() Returns the total number of times that
the thread associated with this
| |
| getWaitedTime | back to summary |
|---|---|
| public long getWaitedTime() Returns the approximate accumulated elapsed time (in milliseconds)
that the thread associated with this The Java virtual machine may measure the time with a high resolution timer. This statistic is reset when the thread contention monitoring is re-enabled.
| |
| initialize | back to summary |
|---|---|
| private void initialize(Thread t, int state, Object lockObj, Thread lockOwner, long blockedCount, long blockedTime, long waitedCount, long waitedTime, StackTraceElement[] stackTrace, MonitorInfo[] lockedMonitors, LockInfo[] lockedSynchronizers) Initialize ThreadInfo object
| |
| isDaemon | back to summary |
|---|---|
| public boolean isDaemon() Tests if the thread associated with this
| |
| isInNative | back to summary |
|---|---|
| public boolean isInNative() Tests if the thread associated with this A thread is considered to be executing native code when it is executing a native method, executing native code invoked using a method handle obtained from the native linker, or is attached to the VM with the Java Native Interface with no Java frames on its stack. Native code does not include Java virtual machine support code, compiled code generated by the Java virtual machine, or special cases such as a thread blocked on a JVM TI raw monitor.
| |
| isSuspended | back to summary |
|---|---|
| public boolean isSuspended() Tests if the thread associated with this
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this thread info. The format of this string depends on the implementation. The returned string will typically include the thread name, the thread ID, its state, and a stack trace if any.
| |