本文整理匯總了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();
}