/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.management;
/**
* Implementation class for the thread subsystem.
* Standard and committed hotspot-specific metrics if any.
*
* ManagementFactory.getThreadMXBean() returns an instance
* of this class.
*/
// default for thread contention monitoring is disabled.
private boolean contentionMonitoringEnabled = false;
private boolean cpuTimeEnabled;
private boolean allocatedMemoryEnabled;
/**
* Constructor of ThreadImpl class.
*/
}
public int getThreadCount() {
return jvm.getLiveThreadCount();
}
public int getPeakThreadCount() {
return jvm.getPeakThreadCount();
}
public long getTotalStartedThreadCount() {
return jvm.getTotalThreadCount();
}
public int getDaemonThreadCount() {
return jvm.getDaemonThreadCount();
}
public boolean isThreadContentionMonitoringSupported() {
return jvm.isThreadContentionMonitoringSupported();
}
public synchronized boolean isThreadContentionMonitoringEnabled() {
if (!isThreadContentionMonitoringSupported()) {
throw new UnsupportedOperationException(
"Thread contention monitoring is not supported.");
}
return contentionMonitoringEnabled;
}
public boolean isThreadCpuTimeSupported() {
return jvm.isOtherThreadCpuTimeSupported();
}
public boolean isCurrentThreadCpuTimeSupported() {
return jvm.isCurrentThreadCpuTimeSupported();
}
public boolean isThreadAllocatedMemorySupported() {
return jvm.isThreadAllocatedMemorySupported();
}
public boolean isThreadCpuTimeEnabled() {
if (!isThreadCpuTimeSupported() &&
throw new UnsupportedOperationException(
"Thread CPU time measurement is not supported");
}
return cpuTimeEnabled;
}
public boolean isThreadAllocatedMemoryEnabled() {
if (!isThreadAllocatedMemorySupported()) {
throw new UnsupportedOperationException(
"Thread allocated memory measurement is not supported");
}
return allocatedMemoryEnabled;
}
public long[] getAllThreadIds() {
for (int i = 0; i < length; i++) {
}
return ids;
}
long[] ids = new long[1];
return infos[0];
}
long[] ids = new long[1];
return infos[0];
}
}
throw new NullPointerException("Null ids parameter.");
}
if (ids[i] <= 0) {
throw new IllegalArgumentException(
"Invalid thread ID parameter: " + ids[i]);
}
}
}
if (maxDepth < 0) {
throw new IllegalArgumentException(
"Invalid maxDepth parameter: " + maxDepth);
}
} else {
}
return infos;
}
if (!isThreadContentionMonitoringSupported()) {
throw new UnsupportedOperationException(
"Thread contention monitoring is not supported");
}
synchronized (this) {
if (contentionMonitoringEnabled != enable) {
if (enable) {
// if reeabled, reset contention time statistics
// for all threads
}
// update the VM of the state change
}
}
}
private boolean verifyCurrentThreadCpuTime() {
// check if Thread CPU time measurement is supported.
if (!isCurrentThreadCpuTimeSupported()) {
throw new UnsupportedOperationException(
"Current thread CPU time measurement is not supported.");
}
return isThreadCpuTimeEnabled();
}
public long getCurrentThreadCpuTime() {
if (verifyCurrentThreadCpuTime()) {
return getThreadTotalCpuTime0(0);
}
return -1;
}
long[] ids = new long[1];
return times[0];
}
// check if Thread CPU time measurement is supported.
if (!isThreadCpuTimeSupported() &&
throw new UnsupportedOperationException(
"Thread CPU time measurement is not supported.");
}
if (!isThreadCpuTimeSupported()) {
// support current thread only
throw new UnsupportedOperationException(
"Thread CPU time measurement is only supported" +
" for the current thread.");
}
}
}
return isThreadCpuTimeEnabled();
}
if (verified) {
if (length == 1) {
id = 0;
}
} else {
}
}
return times;
}
public long getCurrentThreadUserTime() {
if (verifyCurrentThreadCpuTime()) {
return getThreadUserCpuTime0(0);
}
return -1;
}
long[] ids = new long[1];
return times[0];
}
if (verified) {
if (length == 1) {
id = 0;
}
} else {
}
}
return times;
}
if (!isThreadCpuTimeSupported() &&
throw new UnsupportedOperationException(
"Thread CPU time measurement is not supported");
}
synchronized (this) {
if (cpuTimeEnabled != enable) {
// notify VM of the state change
}
}
}
long[] ids = new long[1];
return sizes[0];
}
// check if Thread allocated memory measurement is supported.
if (!isThreadAllocatedMemorySupported()) {
throw new UnsupportedOperationException(
"Thread allocated memory measurement is not supported.");
}
return isThreadAllocatedMemoryEnabled();
}
if (verified) {
}
return sizes;
}
if (!isThreadAllocatedMemorySupported()) {
throw new UnsupportedOperationException(
"Thread allocated memory measurement is not supported.");
}
synchronized (this) {
if (allocatedMemoryEnabled != enable) {
// notify VM of the state change
}
}
}
public long[] findMonitorDeadlockedThreads() {
return null;
}
}
return ids;
}
public long[] findDeadlockedThreads() {
if (!isSynchronizerUsageSupported()) {
throw new UnsupportedOperationException(
"Monitoring of Synchronizer Usage is not supported.");
}
return null;
}
}
return ids;
}
public void resetPeakThreadCount() {
}
public boolean isObjectMonitorUsageSupported() {
return jvm.isObjectMonitorUsageSupported();
}
public boolean isSynchronizerUsageSupported() {
return jvm.isSynchronizerUsageSupported();
}
boolean lockedSynchronizers) {
if (lockedMonitors && !isObjectMonitorUsageSupported()) {
throw new UnsupportedOperationException(
"Monitoring of Object Monitor Usage is not supported.");
}
if (lockedSynchronizers && !isSynchronizerUsageSupported()) {
throw new UnsupportedOperationException(
"Monitoring of Synchronizer Usage is not supported.");
}
}
boolean lockedMonitors,
boolean lockedSynchronizers) {
}
boolean lockedSynchronizers) {
}
// VM support where maxDepth == -1 to request entire stack dump
int maxDepth,
ThreadInfo[] result);
private static native void resetPeakThreadCount0();
boolean lockedMonitors,
boolean lockedSynchronizers);
// tid == 0 to reset contention times for all threads
}
}