jdk/src/share/classes/java/lang/management/ThreadMXBean.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 401 ef01e0dccd63
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The management interface for the thread system of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * the Java virtual machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p> A Java virtual machine has a single instance of the implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * class of this interface.  This instance implementing this interface is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * an <a href="ManagementFactory.html#MXBean">MXBean</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * that can be obtained by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * the {@link ManagementFactory#getThreadMXBean} method or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * from the {@link ManagementFactory#getPlatformMBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * platform <tt>MBeanServer</tt>} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>The <tt>ObjectName</tt> for uniquely identifying the MXBean for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the thread system within an MBeanServer is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *    {@link ManagementFactory#THREAD_MXBEAN_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *           <tt>java.lang:type=Threading</tt>}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <h4>Thread ID</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Thread ID is a positive long value returned by calling the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * {@link java.lang.Thread#getId} method for a thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * The thread ID is unique during its lifetime.  When a thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * is terminated, this thread ID may be reused.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <p> Some methods in this interface take a thread ID or an array
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * of thread IDs as the input parameter and return per-thread information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <h4>Thread CPU time</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * A Java virtual machine implementation may support measuring
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * the CPU time for the current thread, for any thread, or for no threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * The {@link #isThreadCpuTimeSupported} method can be used to determine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * if a Java virtual machine supports measuring of the CPU time for any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * thread.  The {@link #isCurrentThreadCpuTimeSupported} method can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * be used to determine if a Java virtual machine supports measuring of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * the CPU time for the current  thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * A Java virtual machine implementation that supports CPU time measurement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * for any thread will also support that for the current thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * <p> The CPU time provided by this interface has nanosecond precision
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * but not necessarily nanosecond accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * A Java virtual machine may disable CPU time measurement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * by default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * The {@link #isThreadCpuTimeEnabled} and {@link #setThreadCpuTimeEnabled}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * methods can be used to test if CPU time measurement is enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * and to enable/disable this support respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * Enabling thread CPU measurement could be expensive in some
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * Java virtual machine implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <h4>Thread Contention Monitoring</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * Some Java virtual machines may support thread contention monitoring.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * When thread contention monitoring is enabled, the accumulated elapsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * time that the thread has blocked for synchronization or waited for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * notification will be collected and returned in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * <a href="ThreadInfo.html#SyncStats"><tt>ThreadInfo</tt></a> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * The {@link #isThreadContentionMonitoringSupported} method can be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * determine if a Java virtual machine supports thread contention monitoring.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * The thread contention monitoring is disabled by default.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * {@link #setThreadContentionMonitoringEnabled} method can be used to enable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * thread contention monitoring.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * <h4>Synchronization Information and Deadlock Detection</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * Some Java virtual machines may support monitoring of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * {@linkplain #isObjectMonitorUsageSupported object monitor usage} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * {@linkplain #isSynchronizerUsageSupported ownable synchronizer usage}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * The {@link #getThreadInfo(long[], boolean, boolean)} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * {@link #dumpAllThreads} methods can be used to obtain the thread stack trace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * and synchronization information including which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * {@linkplain LockInfo <i>lock</i>} a thread is blocked to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * acquire or waiting on and which locks the thread currently owns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * The <tt>ThreadMXBean</tt> interface provides the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * {@link #findMonitorDeadlockedThreads} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * {@link #findDeadlockedThreads} methods to find deadlocks in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * the running application.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * @see <a href="../../../javax/management/package-summary.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 *      JMX Specification.</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * @see <a href="package-summary.html#examples">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *      Ways to Access MXBeans</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * @author  Mandy Chung
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
public interface ThreadMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Returns the current number of live threads including both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * daemon and non-daemon threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @return the current number of live threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public int getThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * Returns the peak live thread count since the Java virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * started or peak was reset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @return the peak live thread count.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public int getPeakThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Returns the total number of threads created and also started
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * since the Java virtual machine started.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @return the total number of threads started.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public long getTotalStartedThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Returns the current number of live daemon threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @return the current number of live daemon threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public int getDaemonThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * Returns all live thread IDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Some threads included in the returned array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * may have been terminated when this method returns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @return an array of <tt>long</tt>, each is a thread ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public long[] getAllThreadIds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Returns the thread info for a thread of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * <tt>id</tt> with no stack trace.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * This method is equivalent to calling:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *   {@link #getThreadInfo(long, int) getThreadInfo(id, 0);}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * This method returns a <tt>ThreadInfo</tt> object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * the thread information for the thread of the specified ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * The stack trace, locked monitors, and locked synchronizers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * in the returned <tt>ThreadInfo</tt> object will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * be empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * If a thread of the given ID is not alive or does not exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * this method will return <tt>null</tt>.  A thread is alive if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * it has been started and has not yet died.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * <b>MBeanServer access</b>:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * The mapped type of <tt>ThreadInfo</tt> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * <tt>CompositeData</tt> with attributes as specified in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * {@link ThreadInfo#from ThreadInfo.from} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param id the thread ID of the thread. Must be positive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @return a {@link ThreadInfo} object for the thread of the given ID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * with no stack trace, no locked monitor and no synchronizer info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * <tt>null</tt> if the thread of the given ID is not alive or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * it does not exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @throws IllegalArgumentException if <tt>id &lt= 0</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    public ThreadInfo getThreadInfo(long id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Returns the thread info for each thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * whose ID is in the input array <tt>ids</tt> with no stack trace.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * This method is equivalent to calling:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *   {@link #getThreadInfo(long[], int) getThreadInfo}(ids, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * This method returns an array of the <tt>ThreadInfo</tt> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * The stack trace, locked monitors, and locked synchronizers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * in each <tt>ThreadInfo</tt> object will be empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * If a thread of a given ID is not alive or does not exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * the corresponding element in the returned array will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * contain <tt>null</tt>.  A thread is alive if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * it has been started and has not yet died.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * <b>MBeanServer access</b>:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * The mapped type of <tt>ThreadInfo</tt> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <tt>CompositeData</tt> with attributes as specified in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * {@link ThreadInfo#from ThreadInfo.from} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @param ids an array of thread IDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @return an array of the {@link ThreadInfo} objects, each containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * information about a thread whose ID is in the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * element of the input array of IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * with no stack trace, no locked monitor and no synchronizer info.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @throws IllegalArgumentException if any element in the input array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *      <tt>ids</tt> is <tt>&lt= 0</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public ThreadInfo[] getThreadInfo(long[] ids);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * Returns a thread info for a thread of the specified <tt>id</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * with stack trace of a specified number of stack trace elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * The <tt>maxDepth</tt> parameter indicates the maximum number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * {@link StackTraceElement} to be retrieved from the stack trace.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * If <tt>maxDepth == Integer.MAX_VALUE</tt>, the entire stack trace of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * the thread will be dumped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * If <tt>maxDepth == 0</tt>, no stack trace of the thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * will be dumped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * This method does not obtain the locked monitors and locked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * synchronizers of the thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * When the Java virtual machine has no stack trace information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * about a thread or <tt>maxDepth == 0</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * the stack trace in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * <tt>ThreadInfo</tt> object will be an empty array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * <tt>StackTraceElement</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * If a thread of the given ID is not alive or does not exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * this method will return <tt>null</tt>.  A thread is alive if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * it has been started and has not yet died.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * <b>MBeanServer access</b>:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * The mapped type of <tt>ThreadInfo</tt> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * <tt>CompositeData</tt> with attributes as specified in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * {@link ThreadInfo#from ThreadInfo.from} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @param id the thread ID of the thread. Must be positive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @param maxDepth the maximum number of entries in the stack trace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * to be dumped. <tt>Integer.MAX_VALUE</tt> could be used to request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * the entire stack to be dumped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @return a {@link ThreadInfo} of the thread of the given ID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * with no locked monitor and synchronizer info.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * <tt>null</tt> if the thread of the given ID is not alive or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * it does not exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @throws IllegalArgumentException if <tt>id &lt= 0</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @throws IllegalArgumentException if <tt>maxDepth is negative</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    public ThreadInfo getThreadInfo(long id, int maxDepth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Returns the thread info for each thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * whose ID is in the input array <tt>ids</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * with stack trace of a specified number of stack trace elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * The <tt>maxDepth</tt> parameter indicates the maximum number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * {@link StackTraceElement} to be retrieved from the stack trace.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * If <tt>maxDepth == Integer.MAX_VALUE</tt>, the entire stack trace of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * the thread will be dumped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * If <tt>maxDepth == 0</tt>, no stack trace of the thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * will be dumped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * This method does not obtain the locked monitors and locked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * synchronizers of the threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * When the Java virtual machine has no stack trace information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * about a thread or <tt>maxDepth == 0</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * the stack trace in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * <tt>ThreadInfo</tt> object will be an empty array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * <tt>StackTraceElement</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * This method returns an array of the <tt>ThreadInfo</tt> objects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * each is the thread information about the thread with the same index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * as in the <tt>ids</tt> array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * If a thread of the given ID is not alive or does not exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * <tt>null</tt> will be set in the corresponding element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * in the returned array.  A thread is alive if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * it has been started and has not yet died.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * <b>MBeanServer access</b>:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * The mapped type of <tt>ThreadInfo</tt> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * <tt>CompositeData</tt> with attributes as specified in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * {@link ThreadInfo#from ThreadInfo.from} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @param ids an array of thread IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @param maxDepth the maximum number of entries in the stack trace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * to be dumped. <tt>Integer.MAX_VALUE</tt> could be used to request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * the entire stack to be dumped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @return an array of the {@link ThreadInfo} objects, each containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * information about a thread whose ID is in the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * element of the input array of IDs with no locked monitor and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * synchronizer info.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @throws IllegalArgumentException if <tt>maxDepth is negative</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @throws IllegalArgumentException if any element in the input array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *      <tt>ids</tt> is <tt>&lt= 0</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * Tests if the Java virtual machine supports thread contention monitoring.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *   <tt>true</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *     if the Java virtual machine supports thread contention monitoring;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *   <tt>false</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    public boolean isThreadContentionMonitoringSupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * Tests if thread contention monitoring is enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @return <tt>true</tt> if thread contention monitoring is enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *         <tt>false</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @throws java.lang.UnsupportedOperationException if the Java virtual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * machine does not support thread contention monitoring.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @see #isThreadContentionMonitoringSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public boolean isThreadContentionMonitoringEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * Enables or disables thread contention monitoring.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * Thread contention monitoring is disabled by default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @param enable <tt>true</tt> to enable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *               <tt>false</tt> to disable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @throws java.lang.UnsupportedOperationException if the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * virtual machine does not support thread contention monitoring.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     *         ManagementPermission("control").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @see #isThreadContentionMonitoringSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public void setThreadContentionMonitoringEnabled(boolean enable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * Returns the total CPU time for the current thread in nanoseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * The returned value is of nanoseconds precision but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * not necessarily nanoseconds accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * If the implementation distinguishes between user mode time and system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * mode time, the returned CPU time is the amount of time that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * the current thread has executed in user mode or system mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * This is a convenient method for local management use and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * equivalent to calling:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *   {@link #getThreadCpuTime getThreadCpuTime}(Thread.currentThread().getId());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @return the total CPU time for the current thread if CPU time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * measurement is enabled; <tt>-1</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @throws java.lang.UnsupportedOperationException if the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * virtual machine does not support CPU time measurement for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * the current thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * @see #getCurrentThreadUserTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @see #isCurrentThreadCpuTimeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * @see #isThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * @see #setThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    public long getCurrentThreadCpuTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * Returns the CPU time that the current thread has executed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * in user mode in nanoseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * The returned value is of nanoseconds precision but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * not necessarily nanoseconds accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * This is a convenient method for local management use and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * equivalent to calling:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     *   {@link #getThreadUserTime getThreadUserTime}(Thread.currentThread().getId());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * @return the user-level CPU time for the current thread if CPU time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * measurement is enabled; <tt>-1</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * @throws java.lang.UnsupportedOperationException if the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * virtual machine does not support CPU time measurement for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * the current thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @see #getCurrentThreadCpuTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * @see #isCurrentThreadCpuTimeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @see #isThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * @see #setThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public long getCurrentThreadUserTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * Returns the total CPU time for a thread of the specified ID in nanoseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * The returned value is of nanoseconds precision but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * not necessarily nanoseconds accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * If the implementation distinguishes between user mode time and system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * mode time, the returned CPU time is the amount of time that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * the thread has executed in user mode or system mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * If the thread of the specified ID is not alive or does not exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * this method returns <tt>-1</tt>. If CPU time measurement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * is disabled, this method returns <tt>-1</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * A thread is alive if it has been started and has not yet died.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * If CPU time measurement is enabled after the thread has started,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * the Java virtual machine implementation may choose any time up to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * and including the time that the capability is enabled as the point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * where CPU time measurement starts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @param id the thread ID of a thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @return the total CPU time for a thread of the specified ID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * if the thread of the specified ID exists, the thread is alive,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * and CPU time measurement is enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * <tt>-1</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @throws IllegalArgumentException if <tt>id &lt= 0 </tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * @throws java.lang.UnsupportedOperationException if the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * virtual machine does not support CPU time measurement for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * other threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @see #getThreadUserTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @see #isThreadCpuTimeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @see #isThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * @see #setThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    public long getThreadCpuTime(long id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * Returns the CPU time that a thread of the specified ID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * has executed in user mode in nanoseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * The returned value is of nanoseconds precision but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * not necessarily nanoseconds accuracy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * If the thread of the specified ID is not alive or does not exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * this method returns <tt>-1</tt>. If CPU time measurement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * is disabled, this method returns <tt>-1</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * A thread is alive if it has been started and has not yet died.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * If CPU time measurement is enabled after the thread has started,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * the Java virtual machine implementation may choose any time up to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * and including the time that the capability is enabled as the point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * where CPU time measurement starts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @param id the thread ID of a thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @return the user-level CPU time for a thread of the specified ID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * if the thread of the specified ID exists, the thread is alive,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * and CPU time measurement is enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * <tt>-1</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @throws IllegalArgumentException if <tt>id &lt= 0 </tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @throws java.lang.UnsupportedOperationException if the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * virtual machine does not support CPU time measurement for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * other threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @see #getThreadCpuTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @see #isThreadCpuTimeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * @see #isThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * @see #setThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    public long getThreadUserTime(long id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * Tests if the Java virtual machine implementation supports CPU time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * measurement for any thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * A Java virtual machine implementation that supports CPU time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * measurement for any thread will also support CPU time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * measurement for the current thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *   <tt>true</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     *     if the Java virtual machine supports CPU time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     *     measurement for any thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     *   <tt>false</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    public boolean isThreadCpuTimeSupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * Tests if the Java virtual machine supports CPU time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * measurement for the current thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * This method returns <tt>true</tt> if {@link #isThreadCpuTimeSupported}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * returns <tt>true</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     *   <tt>true</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     *     if the Java virtual machine supports CPU time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     *     measurement for current thread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *   <tt>false</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    public boolean isCurrentThreadCpuTimeSupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * Tests if thread CPU time measurement is enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * @return <tt>true</tt> if thread CPU time measurement is enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     *         <tt>false</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * @throws java.lang.UnsupportedOperationException if the Java virtual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * machine does not support CPU time measurement for other threads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * nor for the current thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * @see #isThreadCpuTimeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * @see #isCurrentThreadCpuTimeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    public boolean isThreadCpuTimeEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * Enables or disables thread CPU time measurement.  The default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * is platform dependent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * @param enable <tt>true</tt> to enable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     *               <tt>false</tt> to disable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * @throws java.lang.UnsupportedOperationException if the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * virtual machine does not support CPU time measurement for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * any threads nor for the current thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     *         ManagementPermission("control").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * @see #isThreadCpuTimeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @see #isCurrentThreadCpuTimeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    public void setThreadCpuTimeEnabled(boolean enable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * Finds cycles of threads that are in deadlock waiting to acquire
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * object monitors. That is, threads that are blocked waiting to enter a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * synchronization block or waiting to reenter a synchronization block
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * after an {@link Object#wait Object.wait} call,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * where each thread owns one monitor while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * trying to obtain another monitor already held by another thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * in a cycle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * More formally, a thread is <em>monitor deadlocked</em> if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * part of a cycle in the relation "is waiting for an object monitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * owned by".  In the simplest case, thread A is blocked waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * for a monitor owned by thread B, and thread B is blocked waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * for a monitor owned by thread A.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * This method is designed for troubleshooting use, but not for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * synchronization control.  It might be an expensive operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * This method finds deadlocks involving only object monitors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * To find deadlocks involving both object monitors and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * <a href="LockInfo.html#OwnableSynchronizer">ownable synchronizers</a>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * the {@link #findDeadlockedThreads findDeadlockedThreads} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * should be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @return an array of IDs of the threads that are monitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * deadlocked, if any; <tt>null</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * @see #findDeadlockedThreads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    public long[] findMonitorDeadlockedThreads();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * Resets the peak thread count to the current number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * live threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     *         ManagementPermission("control").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * @see #getPeakThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * @see #getThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    public void resetPeakThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * Finds cycles of threads that are in deadlock waiting to acquire
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * object monitors or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * <a href="LockInfo.html#OwnableSynchronizer">ownable synchronizers</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * Threads are <em>deadlocked</em> in a cycle waiting for a lock of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * these two types if each thread owns one lock while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * trying to acquire another lock already held
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * by another thread in the cycle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * This method is designed for troubleshooting use, but not for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * synchronization control.  It might be an expensive operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * @return an array of IDs of the threads that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * deadlocked waiting for object monitors or ownable synchronizers, if any;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * <tt>null</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * @throws java.lang.UnsupportedOperationException if the Java virtual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * machine does not support monitoriing of ownable synchronizer usage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * @see #isSynchronizerUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * @see #findMonitorDeadlockedThreads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    public long[] findDeadlockedThreads();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * Tests if the Java virtual machine supports monitoring of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * object monitor usage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * @return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     *   <tt>true</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     *     if the Java virtual machine supports monitoring of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     *     object monitor usage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     *   <tt>false</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * @see #dumpAllThreads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    public boolean isObjectMonitorUsageSupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * Tests if the Java virtual machine supports monitoring of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * <a href="LockInfo.html#OwnableSynchronizer">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * ownable synchronizer</a> usage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * @return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     *   <tt>true</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     *     if the Java virtual machine supports monitoring of ownable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     *     synchronizer usage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     *   <tt>false</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * @see #dumpAllThreads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    public boolean isSynchronizerUsageSupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * Returns the thread info for each thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * whose ID is in the input array <tt>ids</tt>, with stack trace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * and synchronization information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * This method obtains a snapshot of the thread information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * for each thread including:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     *    <li>the entire stack trace,</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     *    <li>the object monitors currently locked by the thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     *        if <tt>lockedMonitors</tt> is <tt>true</tt>, and</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     *    <li>the <a href="LockInfo.html#OwnableSynchronizer">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     *        ownable synchronizers</a> currently locked by the thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     *        if <tt>lockedSynchronizers</tt> is <tt>true</tt>.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * This method returns an array of the <tt>ThreadInfo</tt> objects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * each is the thread information about the thread with the same index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * as in the <tt>ids</tt> array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * If a thread of the given ID is not alive or does not exist,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * <tt>null</tt> will be set in the corresponding element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * in the returned array.  A thread is alive if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * it has been started and has not yet died.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * If a thread does not lock any object monitor or <tt>lockedMonitors</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * is <tt>false</tt>, the returned <tt>ThreadInfo</tt> object will have an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * empty <tt>MonitorInfo</tt> array.  Similarly, if a thread does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * lock any synchronizer or <tt>lockedSynchronizers</tt> is <tt>false</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * the returned <tt>ThreadInfo</tt> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * will have an empty <tt>LockInfo</tt> array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * When both <tt>lockedMonitors</tt> and <tt>lockedSynchronizers</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * parameters are <tt>false</tt>, it is equivalent to calling:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     *     {@link #getThreadInfo(long[], int)  getThreadInfo(ids, Integer.MAX_VALUE)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * This method is designed for troubleshooting use, but not for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * synchronization control.  It might be an expensive operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * <b>MBeanServer access</b>:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * The mapped type of <tt>ThreadInfo</tt> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * <tt>CompositeData</tt> with attributes as specified in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * {@link ThreadInfo#from ThreadInfo.from} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * @param  ids an array of thread IDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * @param  lockedMonitors if <tt>true</tt>, retrieves all locked monitors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * @param  lockedSynchronizers if <tt>true</tt>, retrieves all locked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     *             ownable synchronizers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * @return an array of the {@link ThreadInfo} objects, each containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * information about a thread whose ID is in the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * element of the input array of IDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * @throws java.lang.UnsupportedOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     *         <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     *           <li>if <tt>lockedMonitors</tt> is <tt>true</tt> but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     *               the Java virtual machine does not support monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     *               of {@linkplain #isObjectMonitorUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     *               object monitor usage}; or</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     *           <li>if <tt>lockedSynchronizers</tt> is <tt>true</tt> but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     *               the Java virtual machine does not support monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     *               of {@linkplain #isSynchronizerUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     *               ownable synchronizer usage}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     *         </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * @see #isObjectMonitorUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * @see #isSynchronizerUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    public ThreadInfo[] getThreadInfo(long[] ids, boolean lockedMonitors, boolean lockedSynchronizers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * Returns the thread info for all live threads with stack trace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * and synchronization information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * Some threads included in the returned array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * may have been terminated when this method returns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * This method returns an array of {@link ThreadInfo} objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * as specified in the {@link #getThreadInfo(long[], boolean, boolean)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * @param  lockedMonitors if <tt>true</tt>, dump all locked monitors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * @param  lockedSynchronizers if <tt>true</tt>, dump all locked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     *             ownable synchronizers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * @return an array of {@link ThreadInfo} for all live threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * @throws java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     *         exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     *         ManagementPermission("monitor").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * @throws java.lang.UnsupportedOperationException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     *         <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     *           <li>if <tt>lockedMonitors</tt> is <tt>true</tt> but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     *               the Java virtual machine does not support monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     *               of {@linkplain #isObjectMonitorUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     *               object monitor usage}; or</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     *           <li>if <tt>lockedSynchronizers</tt> is <tt>true</tt> but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     *               the Java virtual machine does not support monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     *               of {@linkplain #isSynchronizerUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     *               ownable synchronizer usage}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     *         </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * @see #isObjectMonitorUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * @see #isSynchronizerUsageSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    public ThreadInfo[] dumpAllThreads(boolean lockedMonitors, boolean lockedSynchronizers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
}