1 *java.lang.management.ThreadInfo* *ThreadInfo* Thread information.
3 public class ThreadInfo
4 extends |java.lang.Object|
6 |java.lang.management.ThreadInfo_Description|
7 |java.lang.management.ThreadInfo_Fields|
8 |java.lang.management.ThreadInfo_Constructors|
9 |java.lang.management.ThreadInfo_Methods|
11 ================================================================================
13 *java.lang.management.ThreadInfo_Methods*
14 |java.lang.management.ThreadInfo.from(CompositeData)|Returns a ThreadInfo objec
15 |java.lang.management.ThreadInfo.getBlockedCount()|Returns the total number of
16 |java.lang.management.ThreadInfo.getBlockedTime()|Returns the approximate accum
17 |java.lang.management.ThreadInfo.getLockedMonitors()|Returns an array ofMonitor
18 |java.lang.management.ThreadInfo.getLockedSynchronizers()|Returns an array ofLo
19 |java.lang.management.ThreadInfo.getLockInfo()|Returns the LockInfo of an objec
20 |java.lang.management.ThreadInfo.getLockName()|Returns theLockInfo#toString str
21 |java.lang.management.ThreadInfo.getLockOwnerId()|Returns the ID of the thread
22 |java.lang.management.ThreadInfo.getLockOwnerName()|Returns the name of the thr
23 |java.lang.management.ThreadInfo.getStackTrace()|Returns the stack trace of the
24 |java.lang.management.ThreadInfo.getThreadId()|Returns the ID of the thread ass
25 |java.lang.management.ThreadInfo.getThreadName()|Returns the name of the thread
26 |java.lang.management.ThreadInfo.getThreadState()|Returns the state of the thre
27 |java.lang.management.ThreadInfo.getWaitedCount()|Returns the total number of t
28 |java.lang.management.ThreadInfo.getWaitedTime()|Returns the approximate accumu
29 |java.lang.management.ThreadInfo.isInNative()|Tests if the thread associated wi
30 |java.lang.management.ThreadInfo.isSuspended()|Tests if the thread associated w
31 |java.lang.management.ThreadInfo.toString()|Returns a string representation of
33 *java.lang.management.ThreadInfo_Description*
35 Thread information. ThreadInfo contains the information about a thread
36 including: General thread information
38 Thread ID. Name of the thread.
42 Thread state. The object upon which the thread is blocked due to:
44 waiting to enter a synchronization block/method, or waiting to be notified in a
45 Object.wait(|java.lang.Object|) method, or parking due to a
46 LockSupport.park(|java.util.concurrent.locks.LockSupport|) call.
48 The ID of the thread that owns the object that the thread is blocked. Stack
49 trace of the thread. List of object monitors locked by the thread. List of
50 ownable synchronizers locked by the thread.
52 Synchronization Statistics
54 The number of times that the thread has blocked for synchronization or waited
55 for notification. The accumulated elapsed time that the thread has blocked for
56 synchronization or waited for notification since thread contention
57 monitoring(|java.lang.management.ThreadMXBean|) was enabled. Some Java virtual
58 machine implementation may not support this. The
59 (|java.lang.management.ThreadMXBean|) method can be used to determine if a Java
60 virtual machine supports this.
62 This thread information class is designed for use in monitoring of the system,
63 not for synchronization control.
65 MXBean Mapping ThreadInfo is mapped to a
66 CompositeData(|javax.management.openmbean.CompositeData|) with attributes as
67 specified in the from(|java.lang.management.ThreadInfo|) method.
71 *java.lang.management.ThreadInfo.from(CompositeData)*
73 public static |java.lang.management.ThreadInfo| from(javax.management.openmbean.CompositeData cd)
75 Returns a ThreadInfo object represented by the given CompositeData. The given
76 CompositeData must contain the following attributes unless otherwise specified
83 threadId java.lang.Long
85 threadName java.lang.String
87 threadState java.lang.String
89 suspended java.lang.Boolean
91 inNative java.lang.Boolean
93 blockedCount java.lang.Long
95 blockedTime java.lang.Long
97 waitedCount java.lang.Long
99 waitedTime java.lang.Long
101 lockInfo javax.management.openmbean.CompositeData - the mapped type for
102 (|java.lang.management.LockInfo|) as specified in the
104 type mapping rules of MXBeans(|javax.management.MXBean|) .
106 If cd does not contain this attribute, the LockInfo object will be constructed
107 from the value of the lockName attribute.
109 lockName java.lang.String
111 lockOwnerId java.lang.Long
113 lockOwnerName java.lang.String
115 stackTrace javax.management.openmbean.CompositeData[]
117 Each element is a CompositeData representing StackTraceElement containing the
118 following attributes:
124 className java.lang.String
126 methodName java.lang.String
128 fileName java.lang.String
130 lineNumber java.lang.Integer
132 nativeMethod java.lang.Boolean
138 lockedMonitors javax.management.openmbean.CompositeData[] whose element type is
139 the mapped type for (|java.lang.management.MonitorInfo|) as specified in the
140 Monitor.from(|java.lang.management.MonitorInfo|) method.
142 If cd does not contain this attribute, this attribute will be set to an empty
145 lockedSynchronizers javax.management.openmbean.CompositeData[] whose element
146 type is the mapped type for (|java.lang.management.LockInfo|) as specified in
149 type mapping rules of MXBeans(|javax.management.MXBean|) .
151 If cd does not contain this attribute, this attribute will be set to an empty
157 cd - CompositeData representing a ThreadInfo
159 Returns: a ThreadInfo object represented by cd if cd is not null; null otherwise.
161 *java.lang.management.ThreadInfo.getBlockedCount()*
163 public long getBlockedCount()
165 Returns the total number of times that the thread associated with this
166 ThreadInfo blocked to enter or reenter a monitor. I.e. the number of times a
167 thread has been in the BLOCKED(|java.lang.Thread.State|) state.
171 Returns: the total number of times that the thread entered the BLOCKED state.
173 *java.lang.management.ThreadInfo.getBlockedTime()*
175 public long getBlockedTime()
177 Returns the approximate accumulated elapsed time (in milliseconds) that the
178 thread associated with this ThreadInfo has blocked to enter or reenter a
179 monitor since thread contention monitoring is enabled. I.e. the total
180 accumulated time the thread has been in the BLOCKED(|java.lang.Thread.State|)
181 state since thread contention monitoring was last enabled. This method returns
182 -1 if thread contention monitoring is disabled.
184 The Java virtual machine may measure the time with a high resolution timer.
185 This statistic is reset when the thread contention monitoring is reenabled.
189 Returns: the approximate accumulated elapsed time in milliseconds that a thread entered
190 the BLOCKED state; -1 if thread contention monitoring is disabled.
192 *java.lang.management.ThreadInfo.getLockedMonitors()*
194 public |java.lang.management.MonitorInfo|[] getLockedMonitors()
196 Returns an array of (|java.lang.management.MonitorInfo|) objects, each of which
197 represents an object monitor currently locked by the thread associated with
198 this ThreadInfo. If no locked monitor was requested for this thread info or no
199 monitor is locked by the thread, this method will return a zero-length array.
203 Returns: an array of MonitorInfo objects representing the object monitors locked by the
206 *java.lang.management.ThreadInfo.getLockedSynchronizers()*
208 public |java.lang.management.LockInfo|[] getLockedSynchronizers()
210 Returns an array of (|java.lang.management.LockInfo|) objects, each of which
211 represents an ownable synchronizer currently locked by the thread associated
212 with this ThreadInfo. If no locked synchronizer was requested for this thread
213 info or no synchronizer is locked by the thread, this method will return a
218 Returns: an array of LockInfo objects representing the ownable synchronizers locked by
221 *java.lang.management.ThreadInfo.getLockInfo()*
223 public |java.lang.management.LockInfo| getLockInfo()
225 Returns the LockInfo of an object for which the thread associated with this
226 ThreadInfo is blocked waiting. A thread can be blocked waiting for one of the
229 an object monitor to be acquired for entering or reentering a synchronization
230 block/method. The thread is in the BLOCKED(|java.lang.Thread.State|) state
231 waiting to enter the synchronized statement or method.
233 an object monitor to be notified by another thread. The thread is in the
234 WAITING(|java.lang.Thread.State|) or TIMED_WAITING(|java.lang.Thread.State|)
235 state due to a call to the Object.wait(|java.lang.Object|) method.
237 a synchronization object responsible for the thread parking. The thread is in
238 the WAITING(|java.lang.Thread.State|) or
239 TIMED_WAITING(|java.lang.Thread.State|) state due to a call to the
240 LockSupport.park(|java.util.concurrent.locks.LockSupport|) method. The
241 synchronization object is the object returned from
242 LockSupport.getBlocker(|java.util.concurrent.locks.LockSupport|) method.
243 Typically it is an ownable synchronizer or a
244 Condition(|java.util.concurrent.locks.Condition|) .
246 This method returns null if the thread is not in any of the above conditions.
250 Returns: LockInfo of an object for which the thread is blocked waiting if any; null
253 *java.lang.management.ThreadInfo.getLockName()*
255 public |java.lang.String| getLockName()
257 Returns the string representation(|java.lang.management.LockInfo|) of an object
258 for which the thread associated with this ThreadInfo is blocked waiting. This
259 method is equivalent to calling:
263 getLockInfo().toString()
265 This method will return null if this thread is not blocked waiting for any
266 object or if the object is not owned by any thread.
270 Returns: the string representation of the object on which the thread is blocked if any;
273 *java.lang.management.ThreadInfo.getLockOwnerId()*
275 public long getLockOwnerId()
277 Returns the ID of the thread which owns the object for which the thread
278 associated with this ThreadInfo is blocked waiting. This method will return -1
279 if this thread is not blocked waiting for any object or if the object is not
284 Returns: the thread ID of the owner thread of the object this thread is blocked on; -1
285 if this thread is not blocked or if the object lis not owned by
288 *java.lang.management.ThreadInfo.getLockOwnerName()*
290 public |java.lang.String| getLockOwnerName()
292 Returns the name of the thread which owns the object for which the thread
293 associated with this ThreadInfo is blocked waiting. This method will return
294 null if this thread is not blocked waiting for any object or if the object is
295 not owned by any thread.
299 Returns: the name of the thread that owns the object this thread is blocked on; null if
300 this thread is not blocked or if the object is not owned by any
303 *java.lang.management.ThreadInfo.getStackTrace()*
305 public |java.lang.StackTraceElement|[] getStackTrace()
307 Returns the stack trace of the thread associated with this ThreadInfo. If no
308 stack trace was requested for this thread info, this method will return a
309 zero-length array. If the returned array is of non-zero length then the first
310 element of the array represents the top of the stack, which is the most recent
311 method invocation in the sequence. The last element of the array represents the
312 bottom of the stack, which is the least recent method invocation in the
315 Some Java virtual machines may, under some circumstances, omit one or more
316 stack frames from the stack trace. In the extreme case, a virtual machine that
317 has no stack trace information concerning the thread associated with this
318 ThreadInfo is permitted to return a zero-length array from this method.
322 Returns: an array of StackTraceElement objects of the thread.
324 *java.lang.management.ThreadInfo.getThreadId()*
326 public long getThreadId()
328 Returns the ID of the thread associated with this ThreadInfo.
332 Returns: the ID of the associated thread.
334 *java.lang.management.ThreadInfo.getThreadName()*
336 public |java.lang.String| getThreadName()
338 Returns the name of the thread associated with this ThreadInfo.
342 Returns: the name of the associated thread.
344 *java.lang.management.ThreadInfo.getThreadState()*
346 public |java.lang.Thread.State| getThreadState()
348 Returns the state of the thread associated with this ThreadInfo.
352 Returns: Thread.State of the associated thread.
354 *java.lang.management.ThreadInfo.getWaitedCount()*
356 public long getWaitedCount()
358 Returns the total number of times that the thread associated with this
359 ThreadInfo waited for notification. I.e. the number of times that a thread has
360 been in the WAITING(|java.lang.Thread.State|) or
361 TIMED_WAITING(|java.lang.Thread.State|) state.
365 Returns: the total number of times that the thread was in the WAITING or TIMED_WAITING
368 *java.lang.management.ThreadInfo.getWaitedTime()*
370 public long getWaitedTime()
372 Returns the approximate accumulated elapsed time (in milliseconds) that the
373 thread associated with this ThreadInfo has waited for notification since thread
374 contention monitoring is enabled. I.e. the total accumulated time the thread
375 has been in the WAITING(|java.lang.Thread.State|) or
376 TIMED_WAITING(|java.lang.Thread.State|) state since thread contention
377 monitoring is enabled. This method returns -1 if thread contention monitoring
380 The Java virtual machine may measure the time with a high resolution timer.
381 This statistic is reset when the thread contention monitoring is reenabled.
385 Returns: the approximate accumulated elapsed time in milliseconds that a thread has been
386 in the WAITING or TIMED_WAITING state; -1 if thread contention
387 monitoring is disabled.
389 *java.lang.management.ThreadInfo.isInNative()*
391 public boolean isInNative()
393 Tests if the thread associated with this ThreadInfo is executing native code
394 via the Java Native Interface (JNI). The JNI native code does not include the
395 virtual machine support code or the compiled native code generated by the
400 Returns: true if the thread is executing native code; false otherwise.
402 *java.lang.management.ThreadInfo.isSuspended()*
404 public boolean isSuspended()
406 Tests if the thread associated with this ThreadInfo is suspended. This method
407 returns true if (|java.lang.Thread|) has been called.
411 Returns: true if the thread is suspended; false otherwise.
413 *java.lang.management.ThreadInfo.toString()*
415 public |java.lang.String| toString()
417 Returns a string representation of this thread info. The format of this string
418 depends on the implementation. The returned string will typically include the
419 thread name(|java.lang.management.ThreadInfo|) , the thread
420 ID(|java.lang.management.ThreadInfo|) , its
421 state(|java.lang.management.ThreadInfo|) , and a stack
422 trace(|java.lang.management.ThreadInfo|) if any.
426 Returns: a string representation of this thread info.