當前位置: 首頁>>代碼示例>>Java>>正文


Java MonitorInfo類代碼示例

本文整理匯總了Java中java.lang.management.MonitorInfo的典型用法代碼示例。如果您正苦於以下問題:Java MonitorInfo類的具體用法?Java MonitorInfo怎麽用?Java MonitorInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MonitorInfo類屬於java.lang.management包,在下文中一共展示了MonitorInfo類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: printThreadInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private static StringBuilder printThreadInfo(ThreadInfo ti, StringBuilder sb) {
    // print thread information
    printThread(ti, sb);

    // print stack trace with locks
    StackTraceElement[] stacktrace = ti.getStackTrace();
    MonitorInfo[] monitors = ti.getLockedMonitors();
    for (int i = 0; i < stacktrace.length; i++) {
        StackTraceElement ste = stacktrace[i];
        sb.append("\t at " + ste.toString()).append("\n");
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == i) {
                sb.append("\t  - locked " + mi).append("\n");
            }
        }
    }
    sb.append("\n");
    return sb;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:NbTestCase.java

示例2: printThreadInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private void printThreadInfo(ThreadInfo ti, PrintStream out) {
   printThread(ti, out);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       out.println(INDENT + "at " + ste.toString()); // NOI18N
       for (MonitorInfo mi : monitors) {
           if (mi.getLockedStackDepth() == i) {
               out.println(INDENT + "  - locked " + mi); // NOI18N
           }
       }
   }
   out.println();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:Detector.java

示例3: printThreadInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private static void printThreadInfo(ThreadInfo ti, PrintWriter out) {
  // print thread information
  printThread(ti, out);

  // print stack trace with locks
  StackTraceElement[] stacktrace = ti.getStackTrace();
  MonitorInfo[] monitors = ti.getLockedMonitors();
  for (int i = 0; i < stacktrace.length; i++) {
    StackTraceElement ste = stacktrace[i];
    out.println(INDENT + "at " + ste.toString());
    for (MonitorInfo mi : monitors) {
      if (mi.getLockedStackDepth() == i) {
        out.println(INDENT + "  - locked " + mi);
      }
    }
  }
  out.println();
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:19,代碼來源:TimedOutTestsListener.java

示例4: printThreadInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private void printThreadInfo(ThreadInfo ti) {
   // print thread information
   printThread(ti);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       System.out.println(INDENT + "at " + ste.toString());
       for (MonitorInfo mi : monitors) {
           if (mi.getLockedStackDepth() == i) {
               System.out.println(INDENT + "  - locked " + mi);
           }
       }
   }
   System.out.println();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:ThreadMonitor.java

示例5: isMonitorLockHeldByThread

import java.lang.management.MonitorInfo; //導入依賴的package包/類
public static boolean isMonitorLockHeldByThread(Object o, Thread t) {
    int oihc = System.identityHashCode(o);
    ThreadMXBean tmxbean = ManagementFactory.getThreadMXBean();
    ThreadInfo[] tinfos = tmxbean.dumpAllThreads(true, false);

    for (ThreadInfo ti : tinfos) {
        if (!(t != null && t.getId() != ti.getThreadId())) {
            for (MonitorInfo mi : ti.getLockedMonitors()) {
                if (mi.getIdentityHashCode() == oihc) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:GraalOSRLockTest.java

示例6: generateOrdering

import java.lang.management.MonitorInfo; //導入依賴的package包/類
/**
 * We cannot simply call getLockedMonitors because it is not guaranteed to
 * return the locks in the correct order.
 */
private static void generateOrdering(final List<String> lockOrder,
        ThreadInfo info) {
    final MonitorInfo[] lockedMonitors = info.getLockedMonitors();
    Arrays.sort(lockedMonitors, new Comparator<MonitorInfo>() {
        @Override
        public int compare(MonitorInfo a, MonitorInfo b) {
            return b.getLockedStackDepth() - a.getLockedStackDepth();
        }
    });
    for (MonitorInfo mi : lockedMonitors) {
        String lockName = getObjectName(mi);
        if (lockName.equals("sun.misc.Launcher$AppClassLoader")) {
            // ignore, it shows up everywhere
            continue;
        }
        // Ignore locks which are locked multiple times in
        // succession - Java locks are recursive.
        if (!lockOrder.contains(lockName)) {
            lockOrder.add(lockName);
        }
    }
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:27,代碼來源:AbbaLockingDetector.java

示例7: printThreadInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private void printThreadInfo(ThreadInfo ti, StringBuilder dump) {
   // print thread information
   printThread(ti, dump);

   // print stack trace with locks
   StackTraceElement[] stacktrace = ti.getStackTrace();
   MonitorInfo[] monitors = ti.getLockedMonitors();
   for (int i = 0; i < stacktrace.length; i++) {
       StackTraceElement ste = stacktrace[i];
       dump.append(INDENT + "at " + ste.toString());
       dump.append("\n");
       for (int j = 1; j < monitors.length; j++) {
           MonitorInfo mi = monitors[j];
           if (mi.getLockedStackDepth() == i) {
               dump.append(INDENT + "  - locked " + mi);
               dump.append("\n");
           }
       }
   }
   dump.append("\n");
}
 
開發者ID:irockel,項目名稱:tda,代碼行數:22,代碼來源:MBeanDumper.java

示例8: printThreadInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private void printThreadInfo(ThreadInfo threadInfo) {
    printThread(threadInfo);
    this.sb.append(INDENT).append(threadInfo.toString()).append("\n");
    StackTraceElement[] stacktrace = threadInfo.getStackTrace();
    MonitorInfo[] monitors = threadInfo.getLockedMonitors();

    for (int i = 0; i < stacktrace.length; i++) {
        StackTraceElement ste = stacktrace[i];
        this.sb.append(INDENT).append("at ").append(ste.toString()).append("\n");
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == i) {
                this.sb.append(INDENT).append("  - locked ").append(mi).append("\n");
            }
        }
    }
}
 
開發者ID:icelemon1314,項目名稱:mapleLemon,代碼行數:17,代碼來源:DeadlockDetector.java

示例9: printThreadInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private static void printThreadInfo(ThreadInfo ti, StringBuilder sb) {
    // print thread information
    printThread(ti, sb);

    // print stack trace with locks
    StackTraceElement[] stacktrace = ti.getStackTrace();
    MonitorInfo[] monitors = ti.getLockedMonitors();
    for (int i = 0; i < stacktrace.length; i++) {
        StackTraceElement ste = stacktrace[i];
        sb.append(INDENT);
        sb.append("at ");
        sb.append(ste.toString());
        sb.append(System.getProperty("line.separator"));
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == i) {
                sb.append(INDENT);
                sb.append("  - locked ");
                sb.append(mi);
                sb.append(System.getProperty("line.separator"));
            }
        }
    }
    sb.append(System.getProperty("line.separator"));
}
 
開發者ID:ow2-proactive,項目名稱:scheduling,代碼行數:25,代碼來源:TimedOutTestsListener.java

示例10: printThreadInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private void printThreadInfo(ThreadInfo ti, StringBuilder dump) {
    // print thread information
    printThread(ti, dump);

    // print stack trace with locks
    StackTraceElement[] stacktrace = ti.getStackTrace();
    MonitorInfo[] monitors = ti.getLockedMonitors();
    for (int i = 0; i < stacktrace.length; i++) {
        StackTraceElement ste = stacktrace[i];
        dump.append(TAB).append("at ").append(ste.toString()).append('\n');
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == i) {
                dump.append(TAB).append("  - locked ").append(mi).append('\n');
            }
        }
    }
    dump.append("");
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:19,代碼來源:ThreadDumper.java

示例11: dumpThread

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private static void dumpThread(ThreadInfo thread, Logger log)
{
    log.log( Level.SEVERE, "------------------------------" );
    //
    log.log( Level.SEVERE, "Current Thread: " + thread.getThreadName() );
    log.log( Level.SEVERE, "\tPID: " + thread.getThreadId()
            + " | Suspended: " + thread.isSuspended()
            + " | Native: " + thread.isInNative()
            + " | State: " + thread.getThreadState() );
    if ( thread.getLockedMonitors().length != 0 )
    {
        log.log( Level.SEVERE, "\tThread is waiting on monitor(s):" );
        for ( MonitorInfo monitor : thread.getLockedMonitors() )
        {
            log.log( Level.SEVERE, "\t\tLocked on:" + monitor.getLockedStackFrame() );
        }
    }
    log.log( Level.SEVERE, "\tStack:" );
    //
    for ( StackTraceElement stack : thread.getStackTrace() )
    {
        log.log( Level.SEVERE, "\t\t" + stack );
    }
}
 
開發者ID:pvginkel,項目名稱:Tweakkit-Server,代碼行數:25,代碼來源:WatchdogThread.java

示例12: setMonitorInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private static void setMonitorInfo(TThreadDump threadDump, ThreadInfo threadInfo) {
    MonitorInfo[] monitorInfos = threadInfo.getLockedMonitors();
    if (monitorInfos != null) {
        for (MonitorInfo each : monitorInfos) {
            if (each == null) {
                continue;
            }
            TMonitorInfo tMonitorInfo = new TMonitorInfo();

            tMonitorInfo.setStackDepth(each.getLockedStackDepth());
            tMonitorInfo.setStackFrame(each.getLockedStackFrame().toString());

            threadDump.addToLockedMonitors(tMonitorInfo);
        }
    } else {
        threadDump.setLockedMonitors(Collections.<TMonitorInfo>emptyList());
    }
}
 
開發者ID:naver,項目名稱:pinpoint,代碼行數:19,代碼來源:ThreadDumpUtils.java

示例13: outputMonitors

import java.lang.management.MonitorInfo; //導入依賴的package包/類
@Override
int outputMonitors(ThreadInfo info, int stack_depth, int monitor_pointer, StringBuffer buffer) {
    MonitorInfo[] locked_monitors = info.getLockedMonitors();
    boolean check_next_monitor;
    do
    {
        check_next_monitor = false;
        if (monitor_pointer < locked_monitors.length)
        {
            MonitorInfo monitor_info = locked_monitors[monitor_pointer];
            if (monitor_info.getLockedStackDepth() == stack_depth)
            {
                formatLock(monitor_info, "locked", buffer);
                buffer.append("\n");
                monitor_pointer++;
                check_next_monitor = true;
            }
        }
    } while (check_next_monitor);

    return monitor_pointer;
}
 
開發者ID:workplacesystems,項目名稱:utilsj,代碼行數:23,代碼來源:ThreadDumperJdk16.java

示例14: printMonitorInfo

import java.lang.management.MonitorInfo; //導入依賴的package包/類
private static void printMonitorInfo(ThreadInfo ti, MonitorInfo[] monitors, StringBuilder sb) {
    sb.append("\tLocked monitors: count = " + monitors.length).append("\n");
    for (MonitorInfo mi : monitors) {
        sb.append("\t  - " + mi + " locked at ").append("\n");
        sb.append("\t      " + mi.getLockedStackDepth() + " "
                + mi.getLockedStackFrame()).append("\n");
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:NbTestCase.java


注:本文中的java.lang.management.MonitorInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。