public class ThreadInfo extends Object
Object.wait
方法通知,或LockSupport.park
叫停车。thread contention monitoring
启用。一些java虚拟机的实现可能不支持这个。的ThreadMXBean.isThreadContentionMonitoringSupported()
方法可用来确定是否一个java虚拟机的支持。此线程信息类是专为用于监视系统而设计的,而不是用于同步控制。
CompositeData
属性中指定的
from
方法。
ThreadMXBean.getThreadInfo(long)
,
ThreadMXBean.dumpAllThreads(boolean, boolean)
Modifier and Type | Method and Description |
---|---|
static ThreadInfo |
from(CompositeData cd)
返回一个给定的
CompositeData代表
ThreadInfo对象。
|
long |
getBlockedCount()
返回时间,这
ThreadInfo阻止进入或重新进入监控相关的线程的总数。
|
long |
getBlockedTime()
返回近似的累计时间(以毫秒为单位),这
ThreadInfo关联的线程已经封锁了进入或重新进入监控由于线程争用监控启用。
|
MonitorInfo[] |
getLockedMonitors()
返回
MonitorInfo 对象的数组,每个代表一个对象进行监测,这
ThreadInfo关联的线程锁定目前。
|
LockInfo[] |
getLockedSynchronizers()
返回
LockInfo 对象的数组,其中每一个代表一个
ownable synchronizer采用这种
ThreadInfo关联的线程锁定目前。
|
LockInfo |
getLockInfo()
返回
LockInfo对象与该
ThreadInfo关联的线程阻塞等待。
|
String |
getLockName()
返回
string representation 对象与该
ThreadInfo关联的线程阻塞等待。
|
long |
getLockOwnerId()
返回ID的线程拥有的对象,这
ThreadInfo关联的线程阻塞等待。
|
String |
getLockOwnerName()
返回的名称的线程拥有的对象,这
ThreadInfo关联的线程阻塞等待。
|
StackTraceElement[] |
getStackTrace()
返回这个
ThreadInfo关联的线程的堆栈跟踪。
|
long |
getThreadId()
返回这个
ThreadInfo关联的线程的ID。
|
String |
getThreadName()
返回这个
ThreadInfo相关线程的名字。
|
Thread.State |
getThreadState()
返回这个
ThreadInfo关联的线程的状态。
|
long |
getWaitedCount()
返回时间,这
ThreadInfo关联的线程等待通知的总数。
|
long |
getWaitedTime()
返回近似的累计时间(以毫秒为单位),这
ThreadInfo关联的线程等待线程争用监控启用通知。
|
boolean |
isInNative()
如果这
ThreadInfo关联的线程执行本地代码通过java本地接口(JNI)。
|
boolean |
isSuspended()
如果这
ThreadInfo关联的线程被挂起。
|
String |
toString()
返回此线程信息的字符串表示形式。
|
public long getThreadId()
public String getThreadName()
public Thread.State getThreadState()
public long getBlockedTime()
BLOCKED
状态。此方法返回
-1如果线程争用监控被禁用。
java虚拟机可以测量高分辨率定时器的时间。这一统计重置时,线程争用监控启用。
UnsupportedOperationException
如果java虚拟机不支持此操作。
ThreadMXBean.isThreadContentionMonitoringSupported()
,
ThreadMXBean.setThreadContentionMonitoringEnabled(boolean)
public long getBlockedCount()
BLOCKED
状态数。
public long getWaitedTime()
WAITING
或
TIMED_WAITING
自启用线程争用状态监测。如果线程争用监控被禁用此方法返回
-1。
java虚拟机可以测量高分辨率定时器的时间。这一统计重置时,线程争用监控启用。
UnsupportedOperationException
如果java虚拟机不支持此操作。
ThreadMXBean.isThreadContentionMonitoringSupported()
,
ThreadMXBean.setThreadContentionMonitoringEnabled(boolean)
public long getWaitedCount()
WAITING
或
TIMED_WAITING
状态。
public LockInfo getLockInfo()
BLOCKED
状态等待进入synchronized语句或方法。WAITING
或TIMED_WAITING
由于打电话到Object.wait
方法状态。WAITING
或TIMED_WAITING
由于打电话到LockSupport.park
方法状态。同步对象从LockSupport.getBlocker
方法返回的对象。它通常是一个 ownable synchronizer或Condition
。此方法返回null如果线程不在上述任何条件。
public String getLockName()
string representation
对象与该
ThreadInfo关联的线程阻塞等待。这种方法相当于调用:
getLockInfo().toString()
这个方法将返回null如果线程不阻塞如果对象没有被任何线程拥有等待任何对象或。
getLockInfo()
public long getLockOwnerId()
getLockInfo()
public String getLockOwnerName()
getLockInfo()
public StackTraceElement[] getStackTrace()
一些java虚拟机可以在某些情况下,省略一个或多个堆栈帧从堆栈跟踪。在极端的情况下,虚拟机没有堆栈跟踪信息关于这个ThreadInfo关联的线程被允许返回一零数组长度从这个方法。
public boolean isSuspended()
Thread.suspend()
被称为。
public boolean isInNative()
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
as specified in theLockInfo.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.
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 theMonitor.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 theLockInfo.from(javax.management.openmbean.CompositeData)
method.If cd does not contain this attribute, this attribute will be set to an empty array.
cd
-
CompositeData代表
ThreadInfo
IllegalArgumentException
-如果
cd并不代表上述属性
ThreadInfo。
public MonitorInfo[] getLockedMonitors()
MonitorInfo
对象的数组,每个代表一个对象进行监测,这
ThreadInfo关联的线程锁定目前。如果没有被锁定的监视器被请求为这个线程信息或没有监视器被锁定的线程,这种方法将返回一零个长度数组。
public LockInfo[] getLockedSynchronizers()
LockInfo
对象的数组,其中每一个代表一个
ownable synchronizer采用这种
ThreadInfo关联的线程锁定目前。如果没有锁定的同步请求这个线程的信息或不同步的线程锁定,此方法将返回一零数组长度。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.