Package java.lang.management

Examples of java.lang.management.ThreadMXBean.findDeadlockedThreads()


    // Otherwise, it finds deadlocks involving both monitors and
    // the concurrent locks.
    public long[] findDeadlockedThreads() throws IOException {
        ThreadMXBean tm = getThreadMXBean();
        if (supportsLockUsage && tm.isSynchronizerUsageSupported()) {
            return tm.findDeadlockedThreads();
        } else {
            return tm.findMonitorDeadlockedThreads();
        }
    }
View Full Code Here


        for (ThreadInfo threadInfo : threadInfos)
        {
            dump.append(threadInfo);
        }

        long[] deadLocks = threadMXBean.findDeadlockedThreads();
        if (deadLocks != null && deadLocks.length > 0)
        {
            ThreadInfo[] deadlockedThreads = threadMXBean.getThreadInfo(deadLocks);
            dump.append(String.format("%n"));
            dump.append("Deadlock is detected!");
View Full Code Here

    }

    @Override
    public long[] findDeadlockedThreads() {
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
        return threadMXBean.findDeadlockedThreads();
    }

    @Override
    public boolean isEnabled() {
        return true;
View Full Code Here

    }

    private void addThreadMetrics(List<MetricDatum> list) {
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
        int threadCount = threadMXBean.getThreadCount();
        long[] ids = threadMXBean.findDeadlockedThreads();
        int deadLockThreadCount = ids == null ? 0 : ids.length;
        int daemonThreadCount = threadMXBean.getDaemonThreadCount();
        int peakThreadCount = threadMXBean.getPeakThreadCount();
        long totalStartedThreadCount = threadMXBean.getTotalStartedThreadCount();
        long[] counts = {
View Full Code Here

            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");
        }
    }
View Full Code Here

    }


    public static void checkDeadlockedThreads() throws IllegalThreadStateException {
        ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
        long[] ids = tmx.findDeadlockedThreads();
        if (ids != null) {
            ThreadInfo[] infos = tmx.getThreadInfo(ids, true, true);
            String log = "The following threads are deadlocked:\n";
            for (ThreadInfo ti : infos) {
                System.out.println(ti);
View Full Code Here

                    ConditionTimeoutException e = new ConditionTimeoutException(message);

                    ThreadMXBean bean = ManagementFactory.getThreadMXBean();
                    try {
                        long[] threadIds = bean.findDeadlockedThreads();
                        if (threadIds != null)
                            e.initCause(new DeadlockException(threadIds));
                    }
                    catch (UnsupportedOperationException ignored) {
                        // findDeadLockedThreads() not supported on this VM,
View Full Code Here

       
        if(!executorService.isTerminated()) {
            /* uncomment this block to perform deadlock checking, only on java 1.6 */
            // Check for deadlock
            ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
            long[] ids = tmx.findDeadlockedThreads();
            if (ids != null) {
                ThreadInfo[] infos = tmx.getThreadInfo(ids, true, true);
               
                System.err.println("*** Deadlocked threads");
                for (ThreadInfo ti : infos) {
View Full Code Here

   */
  private static final class DeadLockDetectionTimerTask extends TimerTask {
    @Override
    public void run() {
      ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
      long[] ids = tmx.findDeadlockedThreads();
      if (ids != null) {
        ThreadInfo[] infos = tmx.getThreadInfo(ids, true, true);
        StringBuilder text = new StringBuilder();
        text.append("The following threads are deadlocked:\n");
        for (ThreadInfo ti : infos) {
View Full Code Here

      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        dead = true;
      }
      ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
      long[] ids = tmx.findDeadlockedThreads();
      if (ids != null) {
        ThreadInfo[] infos = tmx.getThreadInfo(ids, true, true);
        System.out.println("The following threads are deadlocked:");
        for (ThreadInfo ti : infos) {
          System.out.println(ti);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.