java.lang.Object
java.lang.management.ThreadInfo
Information about a snapshot of the state of a thread.
- Since:
- 1.5
-
Method Summary
Modifier and TypeMethodDescriptionstatic ThreadInfo
from
(CompositeData cd) Receives aCompositeData
representing aThreadInfo
object and attempts to return the rootThreadInfo
instance.long
Returns the number of times that the thread represented by thisThreadInfo
has been blocked on any monitor objects.long
If thread contention monitoring is supported and enabled, returns the total amount of time that the thread represented by thisThreadInfo
has spent blocked on any monitor objects.Returns an array ofMonitorInfo
objects, one for every monitor object locked by theThread
corresponding to thisThreadInfo
when it was instantiated.LockInfo[]
Returns an array ofLockInfo
objects, each one containing information on an ownable synchronizer (a synchronizer that makes use of theAbstractOwnableSynchronizer
type and which is completely owned by a single thread) locked by theThread
corresponding to thisThreadInfo
when it was instantiated.If the thread corresponding to thisThreadInfo
is blocked then this method returns aLockInfo
object that contains details of the associated lock object.If the thread represented by thisThreadInfo
is currently blocked on or waiting on a monitor object, returns a string representation of that monitor object.long
If the thread represented by thisThreadInfo
is currently blocked on or waiting on a monitor object, returns the thread identifier of the thread which owns the monitor.If the thread represented by thisThreadInfo
is currently blocked on or waiting on a monitor object, returns the name of the thread which owns the monitor.int
Returns the thread priority of the thread represented by thisThreadInfo
.If available, returns the stack trace for the thread represented by thisThreadInfo
instance.long
Returns the thread identifier of the thread represented by thisThreadInfo
.Returns the name of the thread represented by thisThreadInfo
.Returns the thread state value of the thread represented by thisThreadInfo
.long
The number of times that the thread represented by thisThreadInfo
has gone to the "wait" or "timed wait" state.long
If thread contention monitoring is supported and enabled, returns the total amount of time that the thread represented by thisThreadInfo
has spent waiting for notifications.boolean
isDaemon()
Returns aboolean
indication of whether or not the thread represented by thisThreadInfo
is currently a daemon thread.boolean
Returns aboolean
indication of whether or not the thread represented by thisThreadInfo
is currently in a native method.boolean
Returns aboolean
indication of whether or not the thread represented by thisThreadInfo
is currently suspended.toString()
Answers a string containing a concise, human-readable description of the receiver.
-
Method Details
-
getBlockedCount
public long getBlockedCount()Returns the number of times that the thread represented by thisThreadInfo
has been blocked on any monitor objects. The count is from the start of the thread's life.- Returns:
- the number of times the corresponding thread has been blocked on a monitor.
-
getBlockedTime
public long getBlockedTime()If thread contention monitoring is supported and enabled, returns the total amount of time that the thread represented by thisThreadInfo
has spent blocked on any monitor objects. The time is measured in milliseconds and will be measured over the time period since thread contention was most recently enabled.- Returns:
- if thread contention monitoring is currently enabled, the number
of milliseconds that the thread associated with this
ThreadInfo
has spent blocked on any monitors. If thread contention monitoring is supported but currently disabled,-1
. - Throws:
UnsupportedOperationException
- if the virtual machine does not support thread contention monitoring.- See Also:
-
getLockName
If the thread represented by thisThreadInfo
is currently blocked on or waiting on a monitor object, returns a string representation of that monitor object.The monitor's string representation is comprised of the following component parts:
monitor
class name@
Integer.toHexString(System.identityHashCode(monitor))
- Returns:
- if blocked or waiting on a monitor, a string representation of
the monitor object. Otherwise,
null
. - See Also:
-
getLockOwnerId
public long getLockOwnerId()If the thread represented by thisThreadInfo
is currently blocked on or waiting on a monitor object, returns the thread identifier of the thread which owns the monitor.- Returns:
- the thread identifier of the other thread which holds the monitor
that the thread associated with this
ThreadInfo
is blocked or waiting on. If thisThreadInfo
's associated thread is currently not blocked or waiting, or there is no other thread holding the monitor, returns a-1
.
-
getLockOwnerName
If the thread represented by thisThreadInfo
is currently blocked on or waiting on a monitor object, returns the name of the thread which owns the monitor.- Returns:
- the name of the other thread which holds the monitor that the
thread associated with this
ThreadInfo
is blocked or waiting on. If thisThreadInfo
's associated thread is currently not blocked or waiting, or there is no other thread holding the monitor, returns anull
reference.
-
getLockInfo
If the thread corresponding to thisThreadInfo
is blocked then this method returns aLockInfo
object that contains details of the associated lock object.- Returns:
- a
LockInfo
object if thisThreadInfo
's thread is currently blocked, elsenull
.
-
getStackTrace
If available, returns the stack trace for the thread represented by thisThreadInfo
instance. The stack trace is returned in an array ofStackTraceElement
objects with the "top" of the stack encapsulated in the first array element and the "bottom" of the stack in the last array element.If this
ThreadInfo
was created without any stack trace information (e.g. by a call toThreadMXBean.getThreadInfo(long)
) then the returned array will have a length of zero.- Returns:
- the stack trace for the thread represented by this
ThreadInfo
.
-
getThreadId
public long getThreadId()Returns the thread identifier of the thread represented by thisThreadInfo
.- Returns:
- the identifier of the thread corresponding to this
ThreadInfo
.
-
getThreadName
Returns the name of the thread represented by thisThreadInfo
.- Returns:
- the name of the thread corresponding to this
ThreadInfo
.
-
getThreadState
Returns the thread state value of the thread represented by thisThreadInfo
.- Returns:
- the thread state of the thread corresponding to this
ThreadInfo
. - See Also:
-
getWaitedCount
public long getWaitedCount()The number of times that the thread represented by thisThreadInfo
has gone to the "wait" or "timed wait" state.- Returns:
- the number of times the corresponding thread has been in the "wait" or "timed wait" state.
-
getWaitedTime
public long getWaitedTime()If thread contention monitoring is supported and enabled, returns the total amount of time that the thread represented by thisThreadInfo
has spent waiting for notifications. The time is measured in milliseconds and will be measured over the time period since thread contention was most recently enabled.- Returns:
- if thread contention monitoring is currently enabled, the number
of milliseconds that the thread associated with this
ThreadInfo
has spent waiting notifications. If thread contention monitoring is supported but currently disabled,-1
. - Throws:
UnsupportedOperationException
- if the virtual machine does not support thread contention monitoring.- See Also:
-
isInNative
public boolean isInNative()Returns aboolean
indication of whether or not the thread represented by thisThreadInfo
is currently in a native method.- Returns:
- if the corresponding thread is executing a native method
then
true
, otherwisefalse
.
-
isSuspended
public boolean isSuspended()Returns aboolean
indication of whether or not the thread represented by thisThreadInfo
is currently suspended.- Returns:
- if the corresponding thread is suspended then
true
, otherwisefalse
.
-
getLockedMonitors
Returns an array ofMonitorInfo
objects, one for every monitor object locked by theThread
corresponding to thisThreadInfo
when it was instantiated.- Returns:
- an array whose elements comprise of
MonitorInfo
objects - one for each object monitor locked by thisThreadInfo
object's corresponding thread. If no monitors are locked by the thread then the array will have a length of zero.
-
getLockedSynchronizers
Returns an array ofLockInfo
objects, each one containing information on an ownable synchronizer (a synchronizer that makes use of theAbstractOwnableSynchronizer
type and which is completely owned by a single thread) locked by theThread
corresponding to thisThreadInfo
when it was instantiated.- Returns:
- an array whose elements comprise of
LockInfo
objects - one for each ownable synchronizer locked by thisThreadInfo
object's corresponding thread. If no ownable synchronizer are locked by the thread then the array will have a length of zero.
-
from
Receives aCompositeData
representing aThreadInfo
object and attempts to return the rootThreadInfo
instance.- Parameters:
cd
- aCompositeData
that represents aThreadInfo
.- Returns:
- if
cd
is non-null
, returns a new instance ofThreadInfo
. Ifcd
isnull
, returnsnull
. - Throws:
IllegalArgumentException
- if argumentcd
does not correspond to aThreadInfo
with the following attributes: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
)daemon
(java.lang.Boolean
)priority
(java.lang.Integer
)lockInfo
(javax.management.openmbean.CompositeData
) which holds the simple attributesclassName
(java.lang.String
),identityHashCode
(java.lang.Integer
). In the event that the inputCompositeData
does not hold alockInfo
attribute, the value of thelockName
attribute is used for setting the returned object'sLockInfo
state.lockName
(java.lang.String
)lockOwnerId
(java.lang.Long
)lockOwnerName
(java.lang.String
)stackTrace
(javax.management.openmbean.CompositeData[]
)
stackTrace
array must correspond to ajava.lang.StackTraceElement
and have the following attributes :moduleName
(java.lang.String
)moduleVersion
(java.lang.String
)className
(java.lang.String
)methodName
(java.lang.String
)fileName
(java.lang.String
)lineNumber
(java.lang.Integer
)nativeMethod
(java.lang.Boolean
)
-
isDaemon
public boolean isDaemon()Returns aboolean
indication of whether or not the thread represented by thisThreadInfo
is currently a daemon thread.- Returns:
true
if this thread is a daemon thread, otherwisefalse
.
-
getPriority
public int getPriority()Returns the thread priority of the thread represented by thisThreadInfo
.- Returns:
- The priority of the thread represented by this
ThreadInfo
.
-
toString
Description copied from class:Object
Answers a string containing a concise, human-readable description of the receiver.
-