TopBlend:
Here is the
first difference.
There are 35 differences.
is old.
is new.
java.lang.management
Class ThreadInfo
java.lang.Object
java.lang.management.ThreadInfo
-
public class ThreadInfo
- extends Object
Thread information.
ThreadInfo
contains the information about a thread including:
General thread information
-
Thread ID.
-
Name of the thread.
Execution information
-
Thread state.
-
The object upon which the thread is blocked
due to:
-
The ID of the thread that owns the object that the thread is blocked.
-
Stack trace of the thread.
Synchronization statistics
-
The number of times that the thread has blocked for synchronization or waited for notification.
-
The accumulated elapsed time that the thread has blocked for synchronization or waited for notification since 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.
MXBean Mapping
ThreadInfo
is mapped to a CompositeData with attributes as specified in the
from
is mapped to a
CompositeData
with attributes as specified in the
from
method.
-
Since:
-
1.5
-
See Also:
-
ThreadMXBean.isThreadContentionMonitoringSupported()
Method Summary
|
static
ThreadInfo
|
from
(javax.management.openmbean.CompositeData cd)
(
CompositeData
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. |
LockInfo
String
|
getLockInfo
getLockName
()
Returns the
LockInfo
string representation
of
an object for which
the
monitor lock that the
thread associated with this
ThreadInfo
is blocked
waiting.
to enter or waiting to be notified through the
Object.wait
|
String
long
|
getLockName
getLockOwnerId
()
Returns the
string representation
ID of the thread which holds the monitor lock of an object on which the thread associated with this
ThreadInfo
is
blocked waiting.
blocking.
|
long
String
|
getLockOwnerId
getLockOwnerName
()
Returns the
ID
name
of the thread which
owns
holds
the
monitor lock of an
object
for
on
which the thread associated with this
ThreadInfo
is
blocked waiting.
blocking.
|
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. |
getThreadId
public long getThreadId()
-
Returns the ID of the thread associated with this
ThreadInfo
.
-
-
Returns:
-
the ID of the associated thread.
getThreadName
public String getThreadName()
-
Returns the name of the thread associated with this
ThreadInfo
.
-
-
Returns:
-
the name of the associated thread.
getThreadState
public Thread.State getThreadState()
-
Returns the state of the thread associated with this
ThreadInfo
.
-
-
Returns:
-
Thread.State
of the associated thread.
getBlockedTime
public 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. I.e. the total accumulated time the thread has been in the
BLOCKED
state since thread contention monitoring was last enabled. This method returns
-1
if thread contention monitoring is disabled.
The Java virtual machine may measure the time with a high resolution timer. This statistic is reset when the thread contention monitoring is reenabled.
-
-
Returns:
-
the approximate accumulated elapsed time in milliseconds that a thread entered the
BLOCKED
state;
-1
if thread contention monitoring is disabled.
-
Throws:
-
UnsupportedOperationException
- if the Java virtual machine does not support this operation.
-
See Also:
-
ThreadMXBean.isThreadContentionMonitoringSupported()
,
ThreadMXBean.setThreadContentionMonitoringEnabled(boolean)
getBlockedCount
public long getBlockedCount()
-
Returns the total number of times that the thread associated with this
ThreadInfo
blocked to enter or reenter a monitor. I.e. the number of times a thread has been in the
BLOCKED
state.
-
-
Returns:
-
the total number of times that the thread entered the
BLOCKED
state.
getWaitedTime
public 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. I.e. the total accumulated time the thread has been in the
WAITING
or
TIMED_WAITING
state since thread contention monitoring is enabled. This method returns
-1
if thread contention monitoring is disabled.
The Java virtual machine may measure the time with a high resolution timer. This statistic is reset when the thread contention monitoring is reenabled.
-
-
Returns:
-
the approximate accumulated elapsed time in milliseconds that a thread has been in the
WAITING
or
TIMED_WAITING
state;
-1
if thread contention monitoring is disabled.
-
Throws:
-
UnsupportedOperationException
- if the Java virtual machine does not support this operation.
-
See Also:
-
ThreadMXBean.isThreadContentionMonitoringSupported()
,
ThreadMXBean.setThreadContentionMonitoringEnabled(boolean)
getWaitedCount
public long getWaitedCount()
-
Returns the total number of times that the thread associated with this
ThreadInfo
waited for notification. I.e. the number of times that a thread has been in the
WAITING
or
TIMED_WAITING
state.
-
-
Returns:
-
the total number of times that the thread was in the
WAITING
or
TIMED_WAITING
state.
getLockInfo
public
LockInfo
getLockInfo
()
-
Returns the
LockInfo
of an object for which the thread associated with this
ThreadInfo
is blocked waiting. A thread can be blocked waiting for one of the following:
This method returns
null
if the thread is not in any of the above conditions.
-
-
Returns:
-
LockInfo
of an object for which the thread is blocked waiting if any;
null
otherwise.
-
Since:
-
1.6
getLockName
public String getLockName()
-
Returns the
string representation
string representation
of
an object for which
the
monitor lock that the
thread associated with this
ThreadInfo
is blocked waiting. This method is equivalent to calling:
is blocked to enter or waiting to be notified through the
Object.wait
method. The returned string representation of a monitor lock consists of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the identity hash code of the object. The returned string may not be unique depending on the implementation of the
System.identityHashCode(java.lang.Object)
method. This method returns a string equals to the value of:
getLockInfo().toString()
![](../../../diffpics/oold.gif)
lock.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(lock))
where
lock
is the monitor lock object.
This method will return
If the thread is not blocking to enter on any monitor object, or is not waiting on a monitor object for notification in a
Object.wait
call, this method returns
null
if this thread is not blocked waiting for any object or if the object is not owned by any thread.
.
-
-
Returns:
-
the string representation of the object on which the thread is blocked if any;
the string representation of the monitor lock that the thread is blocking to enter or waiting to be notified through the
Object.wait
method if any;
null
otherwise. -
See Also:
-
getLockInfo()
getLockOwnerId
public long getLockOwnerId()
-
Returns the ID of the thread which
owns
holds
the
monitor lock of an
object
for
on
which the thread associated with this
ThreadInfo
is blocked waiting.
is blocking.
This method will return
-1
if this thread is not blocked
or
waiting
for
on
any
object
monitor,
or if the
object
monitor lock
is not
owned
held
by any thread.
-
-
Returns:
-
the thread ID of the owner thread of the
monitor lock of the
object this thread is
blocked
blocking
on;
-1
if this thread is not blocked or
waiting on any monitor, or
if the
object lis
monitor lock is
not
owned
held
by any thread. -
See Also:
-
getLockInfo()
getLockName()
getLockOwnerName
public String getLockOwnerName()
-
Returns the name of the thread which
owns
holds
the
monitor lock of an
object
for
on
which the thread associated with this
ThreadInfo
is blocked waiting.
is blocking.
This method will return
null
if this thread is not blocked
or
waiting
for
on
any
object
monitor,
or if the
object
monitor lock
is not
owned
held
by any thread.
-
-
Returns:
-
the name of the thread that
owns
holds
the
monitor lock of the
object this thread is
blocked
blocking
on;
null
if this thread is not blocked or
waiting on any monitor, or
if the
object
monitor lock
is not
owned
held
by any thread. -
See Also:
-
getLockInfo()
getLockName()
getStackTrace
public StackTraceElement[] getStackTrace()
-
Returns the stack trace of the thread associated with this
ThreadInfo
. If no stack trace was requested for this thread info, this method will return a zero-length array. If the returned array is of non-zero length then the first element of the array represents the top of the stack, which is the most recent method invocation in the sequence. The last element of the array represents the bottom of the stack, which is the least recent method invocation in the sequence.
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.
-
-
Returns:
-
an array of
StackTraceElement
objects of the thread.
isSuspended
public boolean isSuspended()
-
Tests if the thread associated with this
ThreadInfo
is suspended. This method returns
true
if
Thread.suspend()
has been called.
-
-
Returns:
-
true
if the thread is suspended;
false
otherwise.
isInNative
public boolean isInNative()
-
Tests if the thread associated with this
ThreadInfo
is executing native code via the Java Native Interface (JNI). The JNI native code does not include the virtual machine support code or the compiled native code generated by the virtual machine.
-
-
Returns:
-
true
if the thread is executing native code;
false
otherwise.
toString
public String toString()
-
Returns a string representation of this thread info.
-
-
Overrides:
-
toString
in class
Object
-
-
Returns:
-
a string representation of this thread info.
from
public static ThreadInfofrom
(javax.management.openmbean.CompositeData cd) ![](../../../diffpics/oold.gif)
( ![](../../../diffpics/oold.gif)
CompositeData![](../../../diffpics/oold.gif)
cd)
-
Returns a
ThreadInfo
object represented by the given
CompositeData
. The given
CompositeData
must contain the following
attributes unless otherwise specified below:
attributes:
-
-
Parameters:
-
cd -
CompositeData
representing a
ThreadInfo
-
Returns:
-
a
ThreadInfo
object represented by
cd
if
cd
is not
null
;
null
otherwise.
-
Throws:
-
IllegalArgumentException
- if
cd
does not represent a
ThreadInfo
with the attributes described above.