本文整理汇总了Java中java.lang.management.ThreadMXBean.findDeadlockedThreads方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadMXBean.findDeadlockedThreads方法的具体用法?Java ThreadMXBean.findDeadlockedThreads怎么用?Java ThreadMXBean.findDeadlockedThreads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.management.ThreadMXBean
的用法示例。
在下文中一共展示了ThreadMXBean.findDeadlockedThreads方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dump
import java.lang.management.ThreadMXBean; //导入方法依赖的package包/类
public static ThreadInfo[] dump(int maxDepth,boolean onlyDeadLock){
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
long[] ids ;
if(onlyDeadLock) {
ids = threadBean.findDeadlockedThreads();
}else {
ids = threadBean.getAllThreadIds();
}
if(ids !=null) {
return threadBean.getThreadInfo(ids, maxDepth);
}
else {
return null;
}
}
示例2: main
import java.lang.management.ThreadMXBean; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
MyThread t = new MyThread();
t.setDaemon(true);
t.start();
ThreadMXBean tmbean = ManagementFactory.getThreadMXBean();
if (!tmbean.isSynchronizerUsageSupported()) {
System.out.println("Monitoring of synchronizer usage not supported")
;
return;
}
long[] result = tmbean.findDeadlockedThreads();
if (result != null) {
throw new RuntimeException("TEST FAILED: result should be null");
}
}
示例3: findDeadlockedThreads
import java.lang.management.ThreadMXBean; //导入方法依赖的package包/类
private long[] findDeadlockedThreads(ThreadMXBean mbean)
{
// JDK 1.5 only supports the findMonitorDeadlockedThreads()
// method, so you need to comment out the following three lines
if (mbean.isSynchronizerUsageSupported())
{
return mbean.findDeadlockedThreads();
}
return mbean.findMonitorDeadlockedThreads();
}
示例4: findDeadlockedThreads
import java.lang.management.ThreadMXBean; //导入方法依赖的package包/类
@Override
public long[] findDeadlockedThreads() {
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
return threadMXBean.findDeadlockedThreads();
}