is new.
java.lang.Objectjava.lang.management.ThreadInfo
public class ThreadInfo
Thread information. ThreadInfo contains the information about a thread including:
Stack trace of the thread.
List of object monitors locked by the thread.
List of
ownable synchronizers
locked by the thread.
Synchronization Statistics
thread contention monitoring
This thread information class is designed for use in monitoring of the system, not for synchronization control.
ThreadMXBean.getThreadInfo(long)
,
ThreadMXBean.dumpAllThreads(boolean, boolean)
| Method Summary | |
|---|---|
| static ThreadInfo |
from
(
CompositeData
cd) Returns a ThreadInfo object represented by the given CompositeData . |
| long |
getBlockedCount
() Returns the total number of times that the thread associated with this ThreadInfo blocked to enter or reenter a monitor. |
| long |
getBlockedTime
() Returns the approximate accumulated elapsed time (in milliseconds) that the thread associated with this ThreadInfo has blocked to enter or reenter a monitor since thread contention monitoring is enabled. |
MonitorInfo
|
getLockedMonitors
()
Returns an array of
MonitorInfo
ThreadInfo
.
|
LockInfo
|
getLockedSynchronizers
()
Returns an array of
LockInfo
objects, each of which represents an
ownable synchronizer
ThreadInfo
.
|
| LockInfo |
getLockInfo
() Returns the LockInfo of an object for which the thread associated with this ThreadInfo is blocked waiting. |
| String |
getLockName
() Returns the string representation of an object for which the thread associated with this ThreadInfo is blocked waiting. |
| long |
getLockOwnerId
() Returns the ID of the thread which owns the object for which the thread associated with this ThreadInfo is blocked waiting. |
| String |
getLockOwnerName
() Returns the name of the thread which owns the object for which the thread associated with this ThreadInfo is blocked waiting. |
| StackTraceElement [] |
getStackTrace
() Returns the stack trace of the thread associated with this ThreadInfo . |
| long |
getThreadId
() Returns the ID of the thread associated with this ThreadInfo . |
| String |
getThreadName
() Returns the name of the thread associated with this ThreadInfo . |
| Thread.State |
getThreadState
() Returns the state of the thread associated with this ThreadInfo . |
| long |
getWaitedCount
() Returns the total number of times that the thread associated with this ThreadInfo waited for notification. |
| long |
getWaitedTime
() Returns the approximate accumulated elapsed time (in milliseconds) that the thread associated with this ThreadInfo has waited for notification since thread contention monitoring is enabled. |
| boolean |
isInNative
() Tests if the thread associated with this ThreadInfo is executing native code via the Java Native Interface (JNI). |
| boolean |
isSuspended
() Tests if the thread associated with this ThreadInfo is suspended. |
| String |
toString
() Returns a string representation of this thread info. |
| Methods inherited from class java.lang. Object |
|---|
| clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait |
| Method Detail |
|---|
public long getThreadId()
public String getThreadName()
public Thread.State getThreadState()
public long getBlockedTime()
The Java virtual machine may measure the time with a high resolution timer. This statistic is reset when the thread contention monitoring is reenabled.
public long getBlockedCount()
public long getWaitedTime()
The Java virtual machine may measure the time with a high resolution timer. This statistic is reset when the thread contention monitoring is reenabled.
public long getWaitedCount()
public LockInfo getLockInfo()
This method returns null if the thread is not in any of the above conditions.
public String getLockName()
getLockInfo().toString()
This method will return null if this thread is not blocked waiting for any object or if the object is not owned by any thread.
public long getLockOwnerId()
public String getLockOwnerName()
public StackTraceElement[] getStackTrace()
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 ThreadInfo is permitted to return a zero-length array from this method.
public boolean isSuspended()
public boolean isInNative()
public String toString()
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.
public static ThreadInfo from(CompositeData cd)
Attribute Name Type threadId java.lang.Long threadName java.lang.String threadState java.lang.String suspended java.lang.Boolean inNative java.lang.Boolean blockedCount java.lang.Long blockedTime java.lang.Long waitedCount java.lang.Long waitedTime java.lang.Long lockInfo javax.management.openmbean.CompositeData
- the mapped type for
LockInfo
![]()
CompositeDataas specified in thetype mapping rules
![]()
LockInfo.fromof
MXBeans
.
If cd does not contain this attribute, the LockInfo object will be constructed from the value of the lockName attribute.lockName java.lang.String lockOwnerId java.lang.Long lockOwnerName java.lang.String stackTrace javax.management.openmbean.CompositeData[] Each element is a CompositeData representing StackTraceElement containing the following attributes:
Attribute Name Type className java.lang.String methodName java.lang.String fileName java.lang.String lineNumber java.lang.Integer nativeMethod java.lang.Boolean lockedMonitors
javax.management.openmbean.CompositeData[]
whose element type is the mapped type for
MonitorInfo
as specified in the
Monitor.from
method.
If
cd
does not contain this attribute, this attribute will be set to an empty array.
lockedSynchronizers
javax.management.openmbean.CompositeData[]
whose element type is the mapped type for
LockInfo
as specified in the
type mapping rules
of
MXBeans
.
If
cd
does not contain this attribute, this attribute will be set to an empty array.
getLockedMonitors
public
MonitorInfo
[]
getLockedMonitors
()
Returns an array of
MonitorInfo
objects, each of which represents an object monitor currently locked by the thread associated with this
ThreadInfo
. If no locked monitor was requested for this thread info or no monitor is locked by the thread, this method will return a zero-length array.
Returns:
an array of
MonitorInfo
objects representing the object monitors locked by the thread.
Since:
1.6
getLockedSynchronizers
public
LockInfo
[]
getLockedSynchronizers
()
Returns an array of
LockInfo
objects, each of which represents an
ownable synchronizer
currently locked by the thread associated with this
ThreadInfo
. If no locked synchronizer was requested for this thread info or no synchronizer is locked by the thread, this method will return a zero-length array.
Returns:
an array of
LockInfo
objects representing the ownable synchronizers locked by the thread.
Since:
1.6