Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/jcl/src/java.management/share/classes/java/lang/management/ThreadMXBean.java
12511 views
1
/*[INCLUDE-IF JAVA_SPEC_VERSION >= 8]*/
2
/*
3
*******************************************************************************
4
* Copyright (c) 2005, 2022 IBM Corp. and others
5
*
6
* This program and the accompanying materials are made available under
7
* the terms of the Eclipse Public License 2.0 which accompanies this
8
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
9
* or the Apache License, Version 2.0 which accompanies this distribution and
10
* is available at https://www.apache.org/licenses/LICENSE-2.0.
11
*
12
* This Source Code may also be made available under the following
13
* Secondary Licenses when the conditions for such availability set
14
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
15
* General Public License, version 2 with the GNU Classpath
16
* Exception [1] and GNU General Public License, version 2 with the
17
* OpenJDK Assembly Exception [2].
18
*
19
* [1] https://www.gnu.org/software/classpath/license.html
20
* [2] http://openjdk.java.net/legal/assembly-exception.html
21
*
22
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
23
*******************************************************************************/
24
package java.lang.management;
25
26
/**
27
* The management and monitoring interface for the threading system of the
28
* virtual machine.
29
* <p>
30
* Precisely one instance of this interface will be made available to management
31
* clients.
32
* </p>
33
* <p>
34
* Accessing this <code>MXBean</code> can be done in one of three ways.
35
* <ol>
36
* <li>Invoking the static {@link ManagementFactory#getThreadMXBean} method.
37
* </li>
38
* <li>Using a javax.management.MBeanServerConnection.</li>
39
* <li>Obtaining a proxy MXBean from the static
40
* {@link ManagementFactory#newPlatformMXBeanProxy} method, passing in
41
* &quot;java.lang:type=Threading&quot; for the value of the second parameter.
42
* </li>
43
* </ol>
44
*
45
* @since 1.5
46
*/
47
public interface ThreadMXBean extends PlatformManagedObject {
48
49
/**
50
* Returns the thread identifiers of every thread in this virtual machine
51
* that is currently blocked in a deadlock situation over a monitor object.
52
* A thread is considered to be deadlocked if it is blocked waiting to run
53
* and owns an object monitor that is sought by another blocked thread. Two
54
* or more threads can be in a deadlock cycle. To determine the threads
55
* currently deadlocked by object monitors <i>and</i> ownable synchronizers
56
* use the {@link #findDeadlockedThreads()} method.
57
* <p>
58
* It is recommended that this method be used solely for problem
59
* determination analysis and not as a means of managing thread
60
* synchronization in a virtual machine. This is because the method may be
61
* very expensive to run.
62
* </p>
63
*
64
* @return an array of the identifiers of every thread in the virtual
65
* machine that has been detected as currently being in a deadlock
66
* situation over an object monitor. May be <code>null</code> if
67
* there are currently no threads in that category.
68
* @throws SecurityException
69
* if there is a security manager in effect and the caller does
70
* not have {@link ManagementPermission} of &quot;monitor&quot;.
71
*/
72
public long[] findMonitorDeadlockedThreads();
73
74
/**
75
* Returns an array of the identifiers of all of the threads that are alive
76
* in the current virtual machine. When processing the return from this
77
* method it should <i>not </i> be assumed that each identified thread is
78
* still alive.
79
*
80
* @return the identifiers of all of the threads currently alive in the
81
* virtual machine.
82
*/
83
public long[] getAllThreadIds();
84
85
/**
86
* If supported by the virtual machine, returns the total CPU usage time for
87
* the currently running thread. The returned time will have nanosecond
88
* precision but may not have nanosecond accuracy.
89
* <p>
90
* Method {@link #isCurrentThreadCpuTimeSupported()} may be used to
91
* determine if current thread CPU timing is supported on the virtual
92
* machine. On virtual machines where current thread CPU timing is
93
* supported, the method {@link #isThreadCpuTimeEnabled()} may be used to
94
* determine if thread CPU timing is actually enabled.
95
* </p>
96
* <p>
97
* The return value is identical to that which would be obtained by calling
98
* {@link #getThreadCpuTime} with an argument
99
* <code>Thread.currentThread().getId())</code>.
100
* </p>
101
*
102
* @return on virtual machines where current thread CPU timing is supported
103
* and thread CPU timing is enabled, the number of nanoseconds CPU
104
* usage by the current thread. On virtual machines where current
105
* thread CPU timing is supported but thread CPU timing is not
106
* enabled, <code>-1</code>.
107
* @throws UnsupportedOperationException
108
* if the virtual machine does not support current thread CPU
109
* timing.
110
*
111
*/
112
public long getCurrentThreadCpuTime();
113
114
/**
115
* If supported by the virtual machine, returns the total CPU usage time for
116
* the current thread running in user mode. The returned time will have
117
* nanosecond precision but may not have nanosecond accuracy.
118
* <p>
119
* Method {@link #isCurrentThreadCpuTimeSupported()} may be used to
120
* determine if current thread CPU timing is supported on the virtual
121
* machine. On virtual machines where current thread CPU timing is
122
* supported, the method {@link #isThreadCpuTimeEnabled()} may be used to
123
* determine if thread CPU timing is actually enabled.
124
* </p>
125
* <p>
126
* The return value is identical to that which would be obtained by calling
127
* {@link #getThreadUserTime} with an argument
128
* <code>Thread.currentThread().getId())</code>.
129
* </p>
130
*
131
* @return on virtual machines where current thread CPU timing is supported
132
* and thread CPU timing is enabled, the number of nanoseconds CPU
133
* time used by the current thread running in user mode. On virtual
134
* machines where current thread CPU timing is supported but thread
135
* CPU timing is not enabled, <code>-1</code>.
136
* @throws UnsupportedOperationException
137
* if the virtual machine does not support current thread CPU
138
* timing.
139
*
140
*/
141
public long getCurrentThreadUserTime();
142
143
/**
144
* Returns the number of daemon threads currently alive in the virtual
145
* machine.
146
*
147
* @return the number of currently alive daemon threads.
148
*/
149
public int getDaemonThreadCount();
150
151
/**
152
* Returns the peak number of threads that have ever been alive in the
153
* virtual machine at any one instant since either the virtual machine
154
* start-up or the peak was reset.
155
*
156
* @return the peak number of live threads
157
* @see #resetPeakThreadCount()
158
*/
159
public int getPeakThreadCount();
160
161
/**
162
* Returns the number of threads currently alive in the virtual machine.
163
* This includes both daemon threads and non-daemon threads.
164
*
165
* @return the number of currently alive threads.
166
*/
167
public int getThreadCount();
168
169
/**
170
* If supported by the virtual machine, returns the total CPU usage time for
171
* the thread with the specified identifier. The returned time will have
172
* nanosecond precision but may not have nanosecond accuracy.
173
* <p>
174
* Method {@link #isThreadCpuTimeSupported()} may be used to determine if
175
* the CPU timing of threads is supported on the virtual machine. On virtual
176
* machines where current thread CPU timing is supported, the method
177
* {@link #isThreadCpuTimeEnabled()} may be used to determine if thread CPU
178
* timing is actually enabled.
179
* </p>
180
*
181
* @param id
182
* the identifier for a thread. Must be a positive number greater
183
* than zero.
184
* @return on virtual machines where thread CPU timing is supported and
185
* enabled, and there is a living thread with identifier
186
* <code>id</code>, the number of nanoseconds CPU time used by
187
* the thread. On virtual machines where thread CPU timing is
188
* supported but not enabled, or where there is no living thread
189
* with identifier <code>id</code> present in the virtual machine,
190
* a value of <code>-1</code> is returned.
191
* @throws IllegalArgumentException
192
* if <code>id</code> is &lt;=0.
193
* @throws UnsupportedOperationException
194
* if the virtual machine does not support thread CPU timing.
195
* @see #isThreadCpuTimeSupported()
196
* @see #isThreadCpuTimeEnabled()
197
*/
198
public long getThreadCpuTime(long id);
199
200
/**
201
* Returns a {@link ThreadInfo} object for the thread with the specified
202
* identifier. The returned object will not have a stack trace so that a
203
* call to its <code>getStackTrace()</code> method will result in an empty
204
* <code>StackTraceElement</code> array. Similarly, the returned object
205
* will hold no details of locked synchronizers or locked object monitors
206
* for the specified thread; calls to <code>getLockedMonitors()</code> and
207
* <code>getLockedSynchronizers</code> will both return array values.
208
*
209
* @param id
210
* the identifier for a thread. Must be a positive number greater
211
* than zero.
212
* @return if the supplied <code>id</code> maps to a living thread in the
213
* virtual machine (i.e. a started thread which has not yet died),
214
* this method returns a {@link ThreadInfo} object corresponding to
215
* that thread. Otherwise, returns <code>null</code>.
216
* @throws IllegalArgumentException
217
* if <code>id</code> is &lt;=0.
218
* @throws SecurityException
219
* if there is a security manager in effect and the caller does
220
* not have {@link ManagementPermission} of &quot;monitor&quot;.
221
*/
222
public ThreadInfo getThreadInfo(long id);
223
224
/**
225
* Returns an array of {@link ThreadInfo} objects ; one for each of the
226
* threads specified in the input array of identifiers. None of the objects
227
* in the return array will have a stack trace so that a call to its
228
* <code>getStackTrace()</code> method will result in an empty
229
* <code>StackTraceElement</code> array. Similarly, the returned object
230
* will hold no details of locked synchronizers or locked object monitors
231
* for the specified thread; calls to <code>getLockedMonitors()</code> and
232
* <code>getLockedSynchronizers</code> will both return array values.
233
*
234
* @param ids
235
* an array of thread identifiers. Each one must be a positive
236
* number greater than zero.
237
* @return an array of {@link ThreadInfo} objects with each entry
238
* corresponding to one of the threads specified in the input array
239
* of identifiers. The return array will therefore have an identical
240
* number of elements to the input <code>ids</code> array. If an
241
* entry in the <code>ids</code> array is invalid (there is no
242
* living thread with the supplied identifier in the virtual
243
* machine) then the corresponding entry in the return array will be
244
* a <code>null</code>.
245
* @throws IllegalArgumentException
246
* if any of the entries in the <code>ids</code> array is
247
* &lt;=0.
248
* @throws SecurityException
249
* if there is a security manager in effect and the caller does
250
* not have {@link ManagementPermission} of &quot;monitor&quot;.
251
*/
252
public ThreadInfo[] getThreadInfo(long[] ids);
253
254
/**
255
* Returns an array of {@link ThreadInfo} objects ; one for each of the
256
* threads specified in the <code>ids</code> argument. The stack trace
257
* information in the returned objects will depend on the value of the
258
* <code>maxDepth</code> argument which specifies the maximum number of
259
* {@link StackTraceElement} instances to try and include. A subsequent call
260
* to any of the returned objects' <code>getStackTrace()</code> method
261
* should result in a {@link StackTraceElement} array of up to
262
* <code>maxDepth</code> elements. A <code>maxDepth</code> value of
263
* <code>Integer.MAX_VALUE</code> will attempt to obtain all of the stack
264
* trace information for each specified thread while a <code>maxDepth</code>
265
* value of zero will yield none.
266
* <p>
267
* The returned object will hold no details of locked synchronizers or
268
* locked object monitors for the specified thread; calls to
269
* <code>getLockedMonitors()</code> and
270
* <code>getLockedSynchronizers</code> will both return array values.
271
* </p>
272
*
273
* @param ids
274
* an array of thread identifiers. Each must be a positive number
275
* greater than zero.
276
* @param maxDepth
277
* the <i>maximum </i> number of stack trace entries to be
278
* included in each of the returned <code>ThreadInfo</code>
279
* objects. Supplying <code>Integer.MAX_VALUE</code> attempts
280
* to obtain all of the stack traces. Only a positive value is
281
* expected.
282
* @return an array of <code>ThreadInfo</code> objects. The size of the
283
* array will be identical to that of the <code>ids</code>
284
* argument. Null elements will be placed in the array if the
285
* corresponding thread identifier in <code>ids</code> does not
286
* resolve to a living thread in the virtual machine (i.e. a started
287
* thread which has not yet died).
288
* @throws IllegalArgumentException
289
* if any element in <code>ids</code> is &lt;=0.
290
* @throws IllegalArgumentException
291
* if <code>maxDepth</code> is &lt;0.
292
* @throws SecurityException
293
* if there is a security manager in effect and the caller does
294
* not have {@link ManagementPermission} of &quot;monitor&quot;.
295
*/
296
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth);
297
298
/**
299
* Returns an array of {@link ThreadInfo} objects; one for each of the
300
* threads specified in the <code>ids</code> argument. Each
301
* <code>ThreadInfo</code> will hold details of all of the stack trace
302
* information for each specified thread. The returned
303
* <code>ThreadInfo</code> objects will optionally contain details of all
304
* monitor objects and synchronizers locked by the corresponding thread. In
305
* order to retrieve locked monitor information the
306
* <code>lockedMonitors</code> argument should be set to <code>true</code>;
307
* in order to retrieve locked synchronizers information
308
* <code>lockedSynchronizers</code> should be set to <code>true</code>.
309
* For a given <code>ThreadInfo</code> element of the return array the
310
* optional information may be inspected by calling
311
* {@link ThreadInfo#getLockedMonitors()} and
312
* {@link ThreadInfo#getLockedSynchronizers()} respectively.
313
* <p>
314
* Both <code>lockedMonitors</code> and <code>lockedSynchronizers</code>
315
* arguments should only be set to <code>true</code> if the virtual
316
* machine supports the requested monitoring.
317
* </p>
318
*
319
* @param ids
320
* an array of thread identifiers. Each one must be a positive
321
* number greater than zero.
322
* @param lockedMonitors
323
* boolean indication of whether or not each returned
324
* <code>ThreadInfo</code> should hold information on locked
325
* object monitors
326
* @param lockedSynchronizers
327
* boolean indication of whether or not each returned
328
* <code>ThreadInfo</code> should hold information on locked
329
* synchronizers
330
* @return an array of {@link ThreadInfo} objects with each entry
331
* corresponding to one of the threads specified in the input array
332
* of identifiers. The return array will therefore have an identical
333
* number of elements to the input <code>ids</code> array. If an
334
* entry in the <code>ids</code> array is invalid (there is no
335
* living thread with the supplied identifier in the virtual
336
* machine) then the corresponding entry in the return array will be
337
* a <code>null</code>.
338
* @throws IllegalArgumentException
339
* if any of the entries in the <code>ids</code> array is
340
* &lt;=0.
341
* @throws SecurityException
342
* if there is a security manager in effect and the caller does
343
* not have {@link ManagementPermission} of &quot;monitor&quot;.
344
* @throws UnsupportedOperationException
345
* if either of the following conditions apply:
346
* <ul>
347
* <li><code>lockedMonitors</code> is <code>true</code> but
348
* a call to {@link #isObjectMonitorUsageSupported()} would
349
* result in a <code>false</code> value
350
* <li><code>lockedSynchronizers</code> is <code>true</code>
351
* but a call to {@link #isSynchronizerUsageSupported()} would
352
* result in a <code>false</code> value
353
* </ul>
354
*/
355
public ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors,
356
boolean lockedSynchronizers);
357
358
/**
359
* Returns a {@link ThreadInfo} object for the thread with the specified
360
* identifier. The stack trace information in the returned object will
361
* depend on the value of the <code>maxDepth</code> argument which
362
* specifies the maximum number of {@link StackTraceElement} instances to
363
* include. A subsequent call to the returned object's
364
* <code>getStackTrace()</code> method should then result in a
365
* {@link StackTraceElement} array of up to <code>maxDepth</code>
366
* elements. A <code>maxDepth</code> value of
367
* <code>Integer.MAX_VALUE</code> will obtain all of the stack trace
368
* information for the thread while a <code>maxDepth</code> value of zero
369
* will yield none.
370
* <p>
371
* It is possible that the virtual machine may be unable to supply any stack
372
* trace information for the specified thread. In that case the returned
373
* <code>ThreadInfo</code> object will have an empty array of
374
* <code>StackTraceElement</code>s.
375
* </p>
376
* <p>
377
* The returned object will hold no details of locked synchronizers or
378
* locked object monitors for the specified thread; calls to
379
* <code>getLockedMonitors()</code> and
380
* <code>getLockedSynchronizers</code> will both return array values.
381
* </p>
382
*
383
* @param id
384
* the identifier for a thread. Must be a positive number greater
385
* than zero.
386
* @param maxDepth
387
* the <i>maximum </i> number of stack trace entries to be
388
* included in the returned <code>ThreadInfo</code> object.
389
* Supplying <code>Integer.MAX_VALUE</code> obtains all of the
390
* stack trace. Only a positive value is expected.
391
* @return if the supplied <code>id</code> maps to a living thread in the
392
* virtual machine (i.e. a started thread which has not yet died),
393
* this method returns a {@link ThreadInfo} object corresponding to
394
* that thread. Otherwise, returns <code>null</code>.
395
* @throws IllegalArgumentException
396
* if <code>id</code> is &lt;=0.
397
* @throws IllegalArgumentException
398
* if <code>maxDepth</code> is &lt;0.
399
* @throws SecurityException
400
* if there is a security manager in effect and the caller does
401
* not have {@link ManagementPermission} of &quot;monitor&quot;.
402
*/
403
public ThreadInfo getThreadInfo(long id, int maxDepth);
404
405
/**
406
* If supported by the virtual machine, returns the total CPU usage time for
407
* the thread with the specified identifier when running in user mode. The
408
* returned time will have nanosecond precision but may not have nanosecond
409
* accuracy.
410
* <p>
411
* Method {@link #isThreadCpuTimeSupported()} may be used to determine if
412
* the CPU timing of threads is supported on the virtual machine. On virtual
413
* machines where current thread CPU timing is supported, the method
414
* {@link #isThreadCpuTimeEnabled()} may be used to determine if thread CPU
415
* timing is actually enabled.
416
* </p>
417
*
418
* @param id
419
* the identifier for a thread. Must be a positive number greater
420
* than zero.
421
* @return on virtual machines where thread CPU timing is supported and
422
* enabled, and there is a living thread with identifier
423
* <code>id</code>, the number of nanoseconds CPU time used by
424
* the thread running in user mode. On virtual machines where thread
425
* CPU timing is supported but not enabled, or where there is no
426
* living thread with identifier <code>id</code> present in the
427
* virtual machine, a value of <code>-1</code> is returned.
428
* <p>
429
* If thread CPU timing was disabled when the thread was started
430
* then the virtual machine is free to choose any measurement start
431
* time between when the virtual machine started up and when thread
432
* CPU timing was enabled with a call to
433
* {@link #setThreadCpuTimeEnabled(boolean)}.
434
* </p>
435
* @throws IllegalArgumentException
436
* if <code>id</code> is &lt;=0.
437
* @throws UnsupportedOperationException
438
* if the virtual machine does not support thread CPU timing.
439
* @see #isThreadCpuTimeSupported()
440
* @see #isThreadCpuTimeEnabled()
441
*/
442
public long getThreadUserTime(long id);
443
444
/**
445
* Returns the number of threads that have been started in this virtual
446
* machine since it came into being.
447
*
448
* @return the total number of started threads.
449
*/
450
public long getTotalStartedThreadCount();
451
452
/**
453
* Returns a boolean indication of whether or not the virtual machine
454
* supports the CPU timing of the current thread.
455
* <p>
456
* Note that this method must return <code>true</code> if
457
* {@link #isThreadCpuTimeSupported()} returns <code>true</code>.
458
* </p>
459
*
460
* @return <code>true</code> if CPU timing of the current thread is
461
* supported, otherwise <code>false</code>.
462
*/
463
public boolean isCurrentThreadCpuTimeSupported();
464
465
/**
466
* Returns a boolean indication of whether or not the monitoring of thread
467
* contention situations is enabled on this virtual machine.
468
*
469
* @return <code>true</code> if thread contention monitoring is enabled,
470
* <code>false</code> otherwise.
471
*/
472
public boolean isThreadContentionMonitoringEnabled();
473
474
/**
475
* Returns a boolean indication of whether or not the monitoring of thread
476
* contention situations is supported on this virtual machine.
477
*
478
* @return <code>true</code> if thread contention monitoring is supported,
479
* <code>false</code> otherwise.
480
*/
481
public boolean isThreadContentionMonitoringSupported();
482
483
/**
484
* Returns a boolean indication of whether or not the CPU timing of threads
485
* is enabled on this virtual machine.
486
*
487
* @return <code>true</code> if thread CPU timing is enabled,
488
* <code>false</code> otherwise.
489
* @throws UnsupportedOperationException
490
* if the virtual machine does not support thread CPU timing.
491
* @see #isThreadCpuTimeSupported()
492
*/
493
public boolean isThreadCpuTimeEnabled();
494
495
/**
496
* Returns a boolean indication of whether or not the virtual machine
497
* supports the CPU time measurement of any threads (current or otherwise).
498
*
499
* @return <code>true</code> if the virtual machine supports the CPU
500
* timing of threads, <code>false</code> otherwise.
501
*/
502
public boolean isThreadCpuTimeSupported();
503
504
/**
505
* Resets the peak thread count to be the current number of threads alive in
506
* the virtual machine when the call is made.
507
*
508
* @throws SecurityException
509
* if there is a security manager in effect and the caller does
510
* not have {@link ManagementPermission} of &quot;control&quot;.
511
*/
512
public void resetPeakThreadCount();
513
514
/**
515
* Updates the virtual machine to either enable or disable the monitoring of
516
* thread contention situations.
517
* <p>
518
* If it is supported, the virtual machine will initially not monitor thread
519
* contention situations.
520
* </p>
521
*
522
* @param enable
523
* enable thread contention monitoring if <code>true</code>,
524
* otherwise disable thread contention monitoring.
525
* @throws SecurityException
526
* if there is a security manager in effect and the caller does
527
* not have {@link ManagementPermission} of &quot;control&quot;.
528
* @throws UnsupportedOperationException
529
* if the virtual machine does not support thread contention
530
* monitoring.
531
* @see #isThreadContentionMonitoringSupported()
532
*/
533
public void setThreadContentionMonitoringEnabled(boolean enable);
534
535
/**
536
* If supported, updates the virtual machine to either enable or disable the
537
* CPU timing of threads.
538
* <p>
539
* The default value of this property depends on the underlying operating
540
* system on which the virtual machine is running.
541
* </p>
542
*
543
* @param enable
544
* enable thread CPU timing if <code>true</code>, otherwise
545
* disable thread CPU timing
546
* @throws SecurityException
547
* if there is a security manager in effect and the caller does
548
* not have {@link ManagementPermission} of &quot;control&quot;.
549
* @throws UnsupportedOperationException
550
* if the virtual machine does not support thread CPU timing.
551
* @see #isThreadCpuTimeSupported()
552
*/
553
public void setThreadCpuTimeEnabled(boolean enable);
554
555
/**
556
* Returns a boolean indication of whether or not the virtual machine
557
* supports the monitoring of object monitor usage.
558
*
559
* @return <code>true</code> if object monitor usage is permitted,
560
* otherwise <code>false</code>
561
* @since 1.6
562
*/
563
public boolean isObjectMonitorUsageSupported();
564
565
/**
566
* Returns a boolean indication of whether or not the virtual machine
567
* supports the monitoring of ownable synchronizers (synchronizers that make
568
* use of the <code>AbstractOwnableSynchronizer</code> type and which are
569
* completely owned by a single thread).
570
*
571
* @return <code>true</code> if synchronizer usage monitoring is
572
* permitted, otherwise <code>false</code>
573
*/
574
public boolean isSynchronizerUsageSupported();
575
576
/**
577
* If supported by the virtual machine, this method can be used to retrieve
578
* the <code>long</code> id of all threads currently waiting on object
579
* monitors or ownable synchronizers (synchronizers that make use of the
580
* <code>AbstractOwnableSynchronizer</code> type and which are completely
581
* owned by a single thread). To determine the threads currently deadlocked
582
* by object monitors only use the {@link #findMonitorDeadlockedThreads()}
583
* method.
584
* <p>
585
* It is recommended that this method be used solely for problem
586
* determination analysis and not as a means of managing thread
587
* synchronization in a virtual machine. This is because the method may be
588
* very expensive to run.
589
* </p>
590
*
591
* @return an array of the identifiers of every thread in the virtual
592
* machine that has been detected as currently being in a deadlock
593
* situation involving object monitors <i>and</i> ownable
594
* synchronizers. If there are no threads in this category a
595
* <code>null</code> is returned.
596
* @throws SecurityException
597
* if there is a security manager in effect and the caller does
598
* not have {@link ManagementPermission} of &quot;monitor&quot;.
599
* @throws UnsupportedOperationException
600
* if the virtual machine does not support any monitoring of
601
* ownable synchronizers.
602
* @see #isSynchronizerUsageSupported()
603
*
604
*/
605
public long[] findDeadlockedThreads();
606
607
/**
608
* Returns an array of {@link ThreadInfo} objects holding information on all
609
* threads that were alive when the call was invoked.
610
*
611
* @param lockedMonitors
612
* boolean indication of whether or not information on all
613
* currently locked object monitors is to be included in the
614
* returned array
615
* @param lockedSynchronizers
616
* boolean indication of whether or not information on all
617
* currently locked ownable synchronizers is to be included in
618
* the returned array
619
* @return an array of <code>ThreadInfo</code> objects
620
* @throws SecurityException
621
* if there is a security manager in effect and the caller does
622
* not have {@link ManagementPermission} of &quot;monitor&quot;.
623
* @throws UnsupportedOperationException
624
* if either of the following conditions apply:
625
* <ul>
626
* <li><code>lockedMonitors</code> is <code>true</code> but
627
* a call to {@link #isObjectMonitorUsageSupported()} would
628
* result in a <code>false</code> value
629
* <li><code>lockedSynchronizers</code> is <code>true</code>
630
* but a call to {@link #isSynchronizerUsageSupported()} would
631
* result in a <code>false</code> value
632
* </ul>
633
*/
634
public ThreadInfo[] dumpAllThreads(boolean lockedMonitors,
635
boolean lockedSynchronizers);
636
637
/*[IF JAVA_SPEC_VERSION >= 10]*/
638
/**
639
* Returns an array of {@link ThreadInfo} objects holding information on all
640
* threads that were alive when the call was invoked.
641
*
642
* @param lockedMonitors
643
* boolean indication of whether or not information on all
644
* currently locked object monitors is to be included in the
645
* returned array
646
* @param lockedSynchronizers
647
* boolean indication of whether or not information on all
648
* currently locked ownable synchronizers is to be included in
649
* the returned array
650
* @param maxDepth limits the number of stack frames returned
651
* @return an array of <code>ThreadInfo</code> objects
652
* @throws SecurityException
653
* if there is a security manager in effect and the caller does
654
* not have {@link ManagementPermission} of &quot;monitor&quot;.
655
* @throws UnsupportedOperationException
656
* if either of the following conditions apply:
657
* <ul>
658
* <li><code>lockedMonitors</code> is <code>true</code> but
659
* a call to {@link #isObjectMonitorUsageSupported()} would
660
* result in a <code>false</code> value</li>
661
* <li><code>lockedSynchronizers</code> is <code>true</code>
662
* but a call to {@link #isSynchronizerUsageSupported()} would
663
* result in a <code>false</code> value</li>
664
* </ul>
665
* @since 10
666
*/
667
public default ThreadInfo[] dumpAllThreads(
668
boolean lockedMonitors, boolean lockedSynchronizers, int maxDepth
669
) {
670
throw new UnsupportedOperationException();
671
}
672
673
/**
674
* Returns an array of {@link ThreadInfo} objects; one for each of the
675
* threads specified in the <code>ids</code> argument. Each
676
* <code>ThreadInfo</code> will hold details of all of the stack trace
677
* information for each specified thread. The returned
678
* <code>ThreadInfo</code> objects will optionally contain details of all
679
* monitor objects and synchronizers locked by the corresponding thread. In
680
* order to retrieve locked monitor information the
681
* <code>lockedMonitors</code> argument should be set to <code>true</code>;
682
* in order to retrieve locked synchronizers information
683
* <code>lockedSynchronizers</code> should be set to <code>true</code>.
684
* For a given <code>ThreadInfo</code> element of the return array the
685
* optional information may be inspected by calling
686
* {@link ThreadInfo#getLockedMonitors()} and
687
* {@link ThreadInfo#getLockedSynchronizers()} respectively.
688
* <p>
689
* Both <code>lockedMonitors</code> and <code>lockedSynchronizers</code>
690
* arguments should only be set to <code>true</code> if the virtual
691
* machine supports the requested monitoring.
692
* </p>
693
*
694
* @param ids
695
* an array of thread identifiers. Each one must be a positive
696
* number greater than zero.
697
* @param lockedMonitors
698
* boolean indication of whether or not each returned
699
* <code>ThreadInfo</code> should hold information on locked
700
* object monitors
701
* @param lockedSynchronizers
702
* boolean indication of whether or not each returned
703
* <code>ThreadInfo</code> should hold information on locked
704
* synchronizers
705
* @param maxDepth limits the number of stack frames returned
706
* @return an array of {@link ThreadInfo} objects with each entry
707
* corresponding to one of the threads specified in the input array
708
* of identifiers. The return array will therefore have an identical
709
* number of elements to the input <code>ids</code> array. If an
710
* entry in the <code>ids</code> array is invalid (there is no
711
* living thread with the supplied identifier in the virtual
712
* machine) then the corresponding entry in the return array will be
713
* a <code>null</code>.
714
* @throws IllegalArgumentException
715
* if any of the entries in the <code>ids</code> array is
716
* &lt;=0.
717
* @throws SecurityException
718
* if there is a security manager in effect and the caller does
719
* not have {@link ManagementPermission} of &quot;monitor&quot;.
720
* @throws UnsupportedOperationException
721
* if either of the following conditions apply:
722
* <ul>
723
* <li><code>lockedMonitors</code> is <code>true</code> but
724
* a call to {@link #isObjectMonitorUsageSupported()} would
725
* result in a <code>false</code> value</li>
726
* <li><code>lockedSynchronizers</code> is <code>true</code>
727
* but a call to {@link #isSynchronizerUsageSupported()} would
728
* result in a <code>false</code> value</li>
729
* </ul>
730
* @since 10
731
*/
732
public default ThreadInfo[] getThreadInfo(
733
long[] ids, boolean lockedMonitors, boolean lockedSynchronizers, int maxDepth
734
) {
735
throw new UnsupportedOperationException();
736
}
737
/*[ENDIF] JAVA_SPEC_VERSION >= 10 */
738
}
739
740