use of java.lang.management.ThreadMXBean in project jgnash by ccavanaugh.
the class EventDispatchThreadHangMonitor method checkForDeadlock.
private static void checkForDeadlock() {
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
long[] threadIds = threadBean.findMonitorDeadlockedThreads();
if (threadIds == null) {
return;
}
Log.warn("deadlock detected involving the following threads:");
ThreadInfo[] threadInfos = threadBean.getThreadInfo(threadIds, Integer.MAX_VALUE);
for (ThreadInfo info : threadInfos) {
Log.warn("Thread #" + info.getThreadId() + " " + info.getThreadName() + " (" + info.getThreadState() + ") waiting on " + info.getLockName() + " held by " + info.getLockOwnerName() + stackTraceToString(info.getStackTrace()));
}
}
use of java.lang.management.ThreadMXBean in project Gargoyle by callakrsos.
the class CPUUsageTest method showThreadBean.
public void showThreadBean() {
ThreadMXBean tbean = ManagementFactory.getThreadMXBean();
long[] ids = tbean.getAllThreadIds();
System.out.println("Thread Count: " + tbean.getThreadCount());
for (long id : ids) {
System.out.println("Thread CPU Time(" + id + ")" + tbean.getThreadCpuTime(id));
System.out.println("Thread User Time(" + id + ")" + tbean.getThreadCpuTime(id));
}
}
use of java.lang.management.ThreadMXBean in project jdk8u_jdk by JetBrains.
the class JvmThreadingImpl method checkJvmThreadContentionMonitoring.
/**
* Checker for the "JvmThreadContentionMonitoring" variable.
*/
public void checkJvmThreadContentionMonitoring(EnumJvmThreadContentionMonitoring x) throws SnmpStatusException {
//Can't be set externaly to unsupported state.
if (JvmThreadContentionMonitoringUnsupported.intValue() == x.intValue()) {
log.debug("checkJvmThreadContentionMonitoring", "Try to set to illegal unsupported value");
throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue);
}
if ((JvmThreadContentionMonitoringEnabled.intValue() == x.intValue()) || (JvmThreadContentionMonitoringDisabled.intValue() == x.intValue())) {
// The value is valid, but is the feature supported ?
ThreadMXBean mbean = getThreadMXBean();
if (mbean.isThreadContentionMonitoringSupported())
return;
log.debug("checkJvmThreadContentionMonitoring", "Unsupported operation, can't set state");
throw new SnmpStatusException(SnmpDefinitions.snmpRspInconsistentValue);
}
log.debug("checkJvmThreadContentionMonitoring", "Try to set to unknown value");
throw new SnmpStatusException(SnmpDefinitions.snmpRspWrongValue);
}
use of java.lang.management.ThreadMXBean in project jdk8u_jdk by JetBrains.
the class JvmThreadInstanceEntryImpl method getJvmThreadInstBlockTimeMs.
/**
* Getter for the "JvmThreadInstBlockTimeMs" variable.
*/
public Long getJvmThreadInstBlockTimeMs() throws SnmpStatusException {
long l = 0;
final ThreadMXBean tmb = JvmThreadingImpl.getThreadMXBean();
if (tmb.isThreadContentionMonitoringSupported()) {
l = info.getBlockedTime();
//Monitoring is disabled
if (l == -1)
l = 0;
}
return new Long(l);
}
use of java.lang.management.ThreadMXBean in project jdk8u_jdk by JetBrains.
the class JvmThreadInstanceEntryImpl method getJvmThreadInstCpuTimeNs.
/**
* Getter for the "JvmThreadInstCpuTimeNs" variable.
*/
public Long getJvmThreadInstCpuTimeNs() throws SnmpStatusException {
long l = 0;
final ThreadMXBean tmb = JvmThreadingImpl.getThreadMXBean();
try {
if (tmb.isThreadCpuTimeSupported()) {
l = tmb.getThreadCpuTime(info.getThreadId());
log.debug("getJvmThreadInstCpuTimeNs", "Cpu time ns : " + l);
//Cpu time measurement is disabled or the id is not valid.
if (l == -1)
l = 0;
}
} catch (UnsatisfiedLinkError e) {
// XXX Revisit: catch TO BE EVENTUALLY REMOVED
log.debug("getJvmThreadInstCpuTimeNs", "Operation not supported: " + e);
}
return new Long(l);
}
Aggregations