Package Summary  Overview Summary

class:ThreadInfo [NONE]


  • public class ThreadInfo
    extends Object
    
    Thread information. ThreadInfo contains the information about a thread including:

    General thread information

    • Thread ID.
    • Name of the thread.
    • Whether a thread is a daemon thread

    Execution information

    • Thread state.
    • The object upon which the thread is blocked due to:
      • waiting to enter a synchronization block/method, or
      • waiting to be notified in a Object.wait method, or
      • parking due to a LockSupport.park call.
    • The ID of the thread that owns the object that the thread is blocked.
    • Stack trace of the thread.
    • List of object monitors locked by the thread.
    • List of ownable synchronizers locked by the thread.
    • Thread priority

    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 method.
    Since:
    1.5
    See Also:
    ThreadMXBean.getThreadInfo(long), ThreadMXBean.dumpAllThreads(boolean, boolean)

method:getThreadId() [NONE]

  • getThreadId

    public long getThreadId()
    Returns the ID of the thread associated with this ThreadInfo.
    Returns:
    the ID of the associated thread.

method:getThreadName() [NONE]

  • getThreadName

    public String getThreadName()
    Returns the name of the thread associated with this ThreadInfo.
    Returns:
    the name of the associated thread.

method:getThreadState() [NONE]

  • getThreadState

    public Thread.State getThreadState()
    Returns the state of the thread associated with this ThreadInfo.
    Returns:
    Thread.State of the associated thread.

method:getBlockedTime() [NONE]

  • 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)

method:getBlockedCount() [NONE]

  • 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.

method:getWaitedTime() [NONE]

  • 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)

method:getWaitedCount() [NONE]

  • 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.

method:getLockInfo() [NONE]

  • 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

method:getLockName() [NONE]

  • getLockName

    public String getLockName()
    Returns the string representation of an object for which the thread associated with this ThreadInfo is blocked waiting. This method is equivalent to calling:
     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.

    Returns:
    the string representation of the object on which the thread is blocked if any; null otherwise.
    See Also:
    getLockInfo()

method:getLockOwnerId() [NONE]

  • getLockOwnerId

    public long getLockOwnerId()
    Returns the ID of the thread which owns the object for which the thread associated with this ThreadInfo is blocked waiting. This method will return -1 if this thread is not blocked waiting for any object or if the object is not owned by any thread.
    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.
    See Also:
    getLockInfo()

method:getLockOwnerName() [NONE]

  • getLockOwnerName

    public String getLockOwnerName()
    Returns the name of the thread which owns the object for which the thread associated with this ThreadInfo is blocked waiting. 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.
    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.
    See Also:
    getLockInfo()

method:getStackTrace() [NONE]

  • 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.

method:isSuspended() [NONE]

  • 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.

method:isInNative() [NONE]

  • 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.

method:isDaemon() [NONE]

  • isDaemon

    public boolean isDaemon()
    Tests if the thread associated with this ThreadInfo is a daemon thread .
    Returns:
    true if the thread is a daemon thread, false otherwise.
    Since:
    9
    See Also:
    Thread.isDaemon()

method:getPriority() [NONE]

  • getPriority

    public int getPriority()
    Returns the thread priority of the thread associated with this ThreadInfo.
    Returns:
    The priority of the thread associated with this ThreadInfo.
    Since:
    9

method:toString() [NONE]

  • toString

    public String toString()
    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.
    Overrides:
    toString in class Object
    Returns:
    a string representation of this thread info.

method:from(javax.management.openmbean.CompositeData) [CHANGED]

  • from

    public static ThreadInfo from​(CompositeData cd)
    Returns a ThreadInfo object represented by the given CompositeData. The given A CompositeData representing a ThreadInfo of version N must contain all of the followingattributes defined in version N unless specified otherwise specified below:. The same rule applies the composite type of the given CompositeData and transitively to attributes whose type or component type is CompositeType.

    A CompositeData representing ThreadInfo of version N contains "stackTrace" attribute and "lockedMonitors" attribute representing an array of StackTraceElement and an array of MonitorInfo respectively and their types are of version N. The "lockedStackFrame" attribute in MonitorInfo's composite type must represent StackTraceElement of the given CompositeData containssame version N. Otherwise, this method will throw IllegalArgumentException. 6
    The attributes and their types for ThreadInfo's composite data
    Attribute Name TypeSince
    threadIdjava.lang.Long5
    threadNamejava.lang.String5
    threadStatejava.lang.String5
    suspendedjava.lang.Boolean5
    inNativejava.lang.Boolean5
    blockedCountjava.lang.Long5
    blockedTimejava.lang.Long5
    waitedCountjava.lang.Long5
    waitedTimejava.lang.Long5
    lockNamejava.lang.String5
    lockOwnerIdjava.lang.Long5
    lockOwnerNamejava.lang.String5
    stackTracejavax.management.openmbean.CompositeData[], each element is a CompositeData representing StackTraceElement as specified below. 5
    lockInfojavax.management.openmbean.CompositeData - the mapped type for LockInfo as specified in the LockInfo.from(javax.management.openmbean.CompositeData) method.

    If cdthe given CompositeData does not contain this attribute, the LockInfo object will be constructed from the value of the lockName attribute.

    lockNamejava.lang.String
    lockOwnerIdjava.lang.Long
    lockOwnerNamejava.lang.String
    stackTracejavax.management.openmbean.CompositeData[]

    Each element is a CompositeData representing StackTraceElement containing the following attributes:
    The attributes and their types the given CompositeData contains
    Attribute Name Type
    moduleNamejava.lang.String
    moduleVersionjava.lang.String
    classNamejava.lang.String
    methodNamejava.lang.String
    fileNamejava.lang.String
    lineNumberjava.lang.Integer
    nativeMethodjava.lang.Boolean

    lockedMonitorsjavax.management.openmbean.CompositeData[] whose element type is the mapped type for MonitorInfo as specified in the MonitorMonitorInfo.from method.

    If cdthe given CompositeData does not contain this attribute, this attribute will be set to an empty array.

    6
    lockedSynchronizersjavax.management.openmbean.CompositeData[] whose element type is the mapped type for LockInfo as specified in the LockInfo.from(javax.management.openmbean.CompositeData) method.

    If cdthe given CompositeData does not contain this attribute, this attribute will be set to an empty array.

    6
    daemonjava.lang.Boolean

    If the given CompositeData does not contain this attribute, this attribute will be set to false.

    9
    priorityjava.lang.Integer

    If the given CompositeData does not contain this attribute, This attribute will be set to Thread.NORM_PRIORITY.

    9
    A CompositeData representing StackTraceElement of version N must contain all of the attributes defined in version N unless specified otherwise.
    The attributes and their types for StackTraceElement's composite data
    Attribute Name TypeSince
    classLoaderNamejava.lang.String9
    moduleNamejava.lang.String9
    moduleVersionjava.lang.String9
    classNamejava.lang.String5
    methodNamejava.lang.String5
    fileNamejava.lang.String5
    lineNumberjava.lang.Integer5
    nativeMethodjava.lang.Boolean5

    Parameters:
    cd - CompositeData representing a ThreadInfo
    Returns:
    a ThreadInfo object represented by cd if cd is not null; null otherwise.
    Throws:
    IllegalArgumentException - if the given cd and its composite type does not representcontain all of the attributes defined for a ThreadInfo with the attributes described aboveof a specific runtime version.
  • from

    public static ThreadInfo from​(CompositeData cd)
    Returns a ThreadInfo object represented by the given CompositeData. The given CompositeData must contain the following attributes unless otherwise specified below:
    The attributes and their types the given CompositeData contains
    Attribute Name Type
    threadIdjava.lang.Long
    threadNamejava.lang.String
    threadStatejava.lang.String
    suspendedjava.lang.Boolean
    inNativejava.lang.Boolean
    blockedCountjava.lang.Long
    blockedTimejava.lang.Long
    waitedCountjava.lang.Long
    waitedTimejava.lang.Long
    lockInfojavax.management.openmbean.CompositeData - the mapped type for LockInfo as specified in the LockInfo.from(javax.management.openmbean.CompositeData) method.

    If cd does not contain this attribute, the LockInfo object will be constructed from the value of the lockName attribute.

    lockNamejava.lang.String
    lockOwnerIdjava.lang.Long
    lockOwnerNamejava.lang.String
    stackTracejavax.management.openmbean.CompositeData[]

    Each element is a CompositeData representing StackTraceElement containing the following attributes:
    The attributes and their types the given CompositeData contains
    Attribute Name Type
    moduleNamejava.lang.String
    moduleVersionjava.lang.String
    classNamejava.lang.String
    methodNamejava.lang.String
    fileNamejava.lang.String
    lineNumberjava.lang.Integer
    nativeMethodjava.lang.Boolean

    lockedMonitorsjavax.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.

    lockedSynchronizersjavax.management.openmbean.CompositeData[] whose element type is the mapped type for LockInfo as specified in the LockInfo.from(javax.management.openmbean.CompositeData) method.

    If cd does not contain this attribute, this attribute will be set to an empty array.

    daemonjava.lang.Boolean
    priorityjava.lang.Integer
    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.
  • from

    public static ThreadInfo from​(CompositeData cd)
    Returns a ThreadInfo object represented by the given CompositeData. A CompositeData representing a ThreadInfo of version N must contain all of the attributes defined in version ≤ N unless specified otherwise. The same rule applies the composite type of the given CompositeData and transitively to attributes whose type or component type is CompositeType.

    A CompositeData representing ThreadInfo of version N contains "stackTrace" attribute and "lockedMonitors" attribute representing an array of StackTraceElement and an array of MonitorInfo respectively and their types are of version N. The "lockedStackFrame" attribute in MonitorInfo's composite type must represent StackTraceElement of the same version N. Otherwise, this method will throw IllegalArgumentException.
    The attributes and their types for ThreadInfo's composite data
    Attribute Name TypeSince
    threadIdjava.lang.Long5
    threadNamejava.lang.String5
    threadStatejava.lang.String5
    suspendedjava.lang.Boolean5
    inNativejava.lang.Boolean5
    blockedCountjava.lang.Long5
    blockedTimejava.lang.Long5
    waitedCountjava.lang.Long5
    waitedTimejava.lang.Long5
    lockNamejava.lang.String5
    lockOwnerIdjava.lang.Long5
    lockOwnerNamejava.lang.String5
    stackTracejavax.management.openmbean.CompositeData[], each element is a CompositeData representing StackTraceElement as specified below. 5
    lockInfojavax.management.openmbean.CompositeData - the mapped type for LockInfo as specified in the LockInfo.from(javax.management.openmbean.CompositeData) method.

    If the given CompositeData does not contain this attribute, the LockInfo object will be constructed from the value of the lockName attribute.

    6
    lockedMonitorsjavax.management.openmbean.CompositeData[] whose element type is the mapped type for MonitorInfo as specified in the MonitorInfo.from method.

    If the given CompositeData does not contain this attribute, this attribute will be set to an empty array.

    6
    lockedSynchronizersjavax.management.openmbean.CompositeData[] whose element type is the mapped type for LockInfo as specified in the LockInfo.from(javax.management.openmbean.CompositeData) method.

    If the given CompositeData does not contain this attribute, this attribute will be set to an empty array.

    6
    daemonjava.lang.Boolean

    If the given CompositeData does not contain this attribute, this attribute will be set to false.

    9
    priorityjava.lang.Integer

    If the given CompositeData does not contain this attribute, This attribute will be set to Thread.NORM_PRIORITY.

    9
    A CompositeData representing StackTraceElement of version N must contain all of the attributes defined in version ≤ N unless specified otherwise.
    The attributes and their types for StackTraceElement's composite data
    Attribute Name TypeSince
    classLoaderNamejava.lang.String9
    moduleNamejava.lang.String9
    moduleVersionjava.lang.String9
    classNamejava.lang.String5
    methodNamejava.lang.String5
    fileNamejava.lang.String5
    lineNumberjava.lang.Integer5
    nativeMethodjava.lang.Boolean5

    Parameters:
    cd - CompositeData representing a ThreadInfo
    Returns:
    a ThreadInfo object represented by cd if cd is not null; null otherwise.
    Throws:
    IllegalArgumentException - if the given cd and its composite type does not contain all of the attributes defined for a ThreadInfo of a specific runtime version.

method:getLockedMonitors() [NONE]

  • 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

method:getLockedSynchronizers() [NONE]

  • 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

© 2018 Oracle Corporation and/or its affiliates