Java Code Examples for java.lang.management.ThreadInfo#isSuspended()

The following examples show how to use java.lang.management.ThreadInfo#isSuspended() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreadMXBeanStateTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static void checkSuspendedThreadState(ThreadStateController t, Thread.State state) {
    ThreadInfo info = getThreadInfo(t, state);
    if (info == null) {
        throw new RuntimeException(t.getName() +
           " expected to have ThreadInfo " +
           " but got null.");
    }

    if (info.getThreadState() != state) {
        throw new RuntimeException(t.getName() + " expected to be in " +
            state + " state but got " + info.getThreadState());
    }

    if (!info.isSuspended()) {
        throw new RuntimeException(t.getName() + " expected to be suspended " +
            " but isSuspended() returns " + info.isSuspended());
    }
}
 
Example 2
Source File: ThreadDumpUtil.java    From pulsar with Apache License 2.0 6 votes vote down vote up
private static void printThread(ThreadInfo ti, PrintWriter out) {
    out.println();
    out.print("\"" + ti.getThreadName() + "\"" + " Id=" + ti.getThreadId() + " in " + ti.getThreadState());
    if (ti.getLockName() != null) {
        out.print(" on lock=" + ti.getLockName());
    }
    if (ti.isSuspended()) {
        out.print(" (suspended)");
    }
    if (ti.isInNative()) {
        out.print(" (running in native)");
    }
    out.println();
    if (ti.getLockOwnerName() != null) {
        out.println(INDENT + " owned by " + ti.getLockOwnerName() + " Id=" + ti.getLockOwnerId());
    }
}
 
Example 3
Source File: ThreadMonitor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void printThread(ThreadInfo ti) {
   StringBuilder sb = new StringBuilder("\"" + ti.getThreadName() + "\"" +
                                        " Id=" + ti.getThreadId() +
                                        " in " + ti.getThreadState());
   if (ti.getLockName() != null) {
       sb.append(" on lock=" + ti.getLockName());
   }
   if (ti.isSuspended()) {
       sb.append(" (suspended)");
   }
   if (ti.isInNative()) {
       sb.append(" (running in native)");
   }
   System.out.println(sb.toString());
   if (ti.getLockOwnerName() != null) {
        System.out.println(INDENT + " owned by " + ti.getLockOwnerName() +
                           " Id=" + ti.getLockOwnerId());
   }
}
 
Example 4
Source File: JvmThreadInstanceEntryImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static Byte[] getState(ThreadInfo info) {
    byte[] bitmap = new byte[] {(byte)0x00, (byte)0x00};
    try {
        final Thread.State state = info.getThreadState();
        final boolean inNative  = info.isInNative();
        final boolean suspended = info.isSuspended();
        log.debug("getJvmThreadInstState",
                  "[State=" + state +
                  ",isInNative=" + inNative +
                  ",isSuspended=" + suspended + "]");
        setState(bitmap,state);
        if (inNative)  setNative(bitmap);
        if (suspended) setSuspended(bitmap);
        checkOther(bitmap);
    } catch (RuntimeException r) {
        bitmap[0]=(byte)0x00;
        bitmap[1]=Byte1.other;
        log.trace("getJvmThreadInstState",
                  "Unexpected exception: " + r);
        log.debug("getJvmThreadInstState",r);
    }
    Byte[] result = { new Byte(bitmap[0]), new Byte(bitmap[1]) };
    return result;
}
 
Example 5
Source File: TimedOutTestsListener.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private static void printThread(ThreadInfo ti, PrintWriter out) {
  out.print("\"" + ti.getThreadName() + "\"" + " Id="
      + ti.getThreadId() + " in " + ti.getThreadState());
  if (ti.getLockName() != null) {
    out.print(" on lock=" + ti.getLockName());
  }
  if (ti.isSuspended()) {
    out.print(" (suspended)");
  }
  if (ti.isInNative()) {
    out.print(" (running in native)");
  }
  out.println();
  if (ti.getLockOwnerName() != null) {
    out.println(INDENT + " owned by " + ti.getLockOwnerName() + " Id="
        + ti.getLockOwnerId());
  }
}
 
Example 6
Source File: ThreadDumpAction.java    From emissary with Apache License 2.0 6 votes vote down vote up
public ThreadDumpInfo(ThreadInfo ti) {
    StringBuilder sb = new StringBuilder();
    if (ti == null) {
        sb.append("A null thread?");
    } else {
        sb.append("\"" + ti.getThreadName() + "\" tid=" + ti.getThreadId() + "\n");
        sb.append("   thread state " + ti.getThreadState()); // no new line
        if (ti.getLockName() != null) {
            sb.append(" (on " + ti.getLockName() + " owned by " + ti.getLockOwnerId() + ")\n");
        }
        if (ti.isSuspended()) {
            sb.append("   SUSPENDED\n");
        }
        if (ti.isInNative()) {
            sb.append("   IN NATIVE CODE\n");
        }
        for (StackTraceElement ste : ti.getStackTrace()) {
            sb.append("      " + ste.toString() + "\n");
        }
    }
    stack = sb.toString();
}
 
Example 7
Source File: ThreadMXBeanStateTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void checkSuspendedThreadState(ThreadStateController t, Thread.State state) {
    ThreadInfo info = getThreadInfo(t, state);
    if (info == null) {
        throw new RuntimeException(t.getName() +
           " expected to have ThreadInfo " +
           " but got null.");
    }

    if (info.getThreadState() != state) {
        throw new RuntimeException(t.getName() + " expected to be in " +
            state + " state but got " + info.getThreadState());
    }

    if (!info.isSuspended()) {
        throw new RuntimeException(t.getName() + " expected to be suspended " +
            " but isSuspended() returns " + info.isSuspended());
    }
}
 
Example 8
Source File: ThreadMonitor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void printThread(ThreadInfo ti) {
   StringBuilder sb = new StringBuilder("\"" + ti.getThreadName() + "\"" +
                                        " Id=" + ti.getThreadId() +
                                        " in " + ti.getThreadState());
   if (ti.getLockName() != null) {
       sb.append(" on lock=" + ti.getLockName());
   }
   if (ti.isSuspended()) {
       sb.append(" (suspended)");
   }
   if (ti.isInNative()) {
       sb.append(" (running in native)");
   }
   System.out.println(sb.toString());
   if (ti.getLockOwnerName() != null) {
        System.out.println(INDENT + " owned by " + ti.getLockOwnerName() +
                           " Id=" + ti.getLockOwnerId());
   }
}
 
Example 9
Source File: TimedOutTestsListener.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
private static void printThread(ThreadInfo ti, PrintWriter out) {
    out.print("\"" + ti.getThreadName() + "\"" + " Id=" + ti.getThreadId() + " in " + ti.getThreadState());
    if (ti.getLockName() != null) {
        out.print(" on lock=" + ti.getLockName());
    }
    if (ti.isSuspended()) {
        out.print(" (suspended)");
    }
    if (ti.isInNative()) {
        out.print(" (running in native)");
    }
    out.println();
    if (ti.getLockOwnerName() != null) {
        out.println(indent + " owned by " + ti.getLockOwnerName() + " Id=" + ti.getLockOwnerId());
    }
}
 
Example 10
Source File: ThreadDumpingWatchdog.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
private static void dumpThreadHeader(StringBuilder sb, ThreadInfo tinfo) {
  sb.append('"').append(tinfo.getThreadName()).append("\" [").append(tinfo.getThreadId())
      .append("] ").append(tinfo.getThreadState());
  if (tinfo.getLockName() != null) {
    sb.append(" on ").append(tinfo.getLockName());
  }
  if (tinfo.getLockOwnerName() != null) {
    sb.append(" owned by '").append(tinfo.getLockOwnerName()).append(" [id:")
        .append(tinfo.getLockOwnerId()).append(']');
  }
  if (tinfo.isSuspended()) {
    sb.append(" (suspended)");
  }
  if (tinfo.isInNative()) {
    sb.append(" (in native code)");
  }
}
 
Example 11
Source File: ThreadMXBeanStateTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void checkSuspendedThreadState(ThreadStateController t, Thread.State state) {
    ThreadInfo info = getThreadInfo(t, state);
    if (info == null) {
        throw new RuntimeException(t.getName() +
           " expected to have ThreadInfo " +
           " but got null.");
    }

    if (info.getThreadState() != state) {
        throw new RuntimeException(t.getName() + " expected to be in " +
            state + " state but got " + info.getThreadState());
    }

    if (!info.isSuspended()) {
        throw new RuntimeException(t.getName() + " expected to be suspended " +
            " but isSuspended() returns " + info.isSuspended());
    }
}
 
Example 12
Source File: ThreadMXBeanStateTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void checkSuspendedThreadState(ThreadStateController t, Thread.State state) {
    ThreadInfo info = getThreadInfo(t, state);
    if (info == null) {
        throw new RuntimeException(t.getName() +
           " expected to have ThreadInfo " +
           " but got null.");
    }

    if (info.getThreadState() != state) {
        throw new RuntimeException(t.getName() + " expected to be in " +
            state + " state but got " + info.getThreadState());
    }

    if (!info.isSuspended()) {
        throw new RuntimeException(t.getName() + " expected to be suspended " +
            " but isSuspended() returns " + info.isSuspended());
    }
}
 
Example 13
Source File: JvmThreadInstanceEntryImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static Byte[] getState(ThreadInfo info) {
    byte[] bitmap = new byte[] {(byte)0x00, (byte)0x00};
    try {
        final Thread.State state = info.getThreadState();
        final boolean inNative  = info.isInNative();
        final boolean suspended = info.isSuspended();
        log.debug("getJvmThreadInstState",
                  "[State=" + state +
                  ",isInNative=" + inNative +
                  ",isSuspended=" + suspended + "]");
        setState(bitmap,state);
        if (inNative)  setNative(bitmap);
        if (suspended) setSuspended(bitmap);
        checkOther(bitmap);
    } catch (RuntimeException r) {
        bitmap[0]=(byte)0x00;
        bitmap[1]=Byte1.other;
        log.trace("getJvmThreadInstState",
                  "Unexpected exception: " + r);
        log.debug("getJvmThreadInstState",r);
    }
    Byte[] result = { new Byte(bitmap[0]), new Byte(bitmap[1]) };
    return result;
}
 
Example 14
Source File: ThreadDump.java    From emissary with Apache License 2.0 5 votes vote down vote up
static void printThreadInfo(final ThreadInfo ti) {
    System.out.println("\"" + ti.getThreadName() + "\" tid=" + ti.getThreadId());
    System.out.println("   thread state " + ti.getThreadState()
            + (ti.getLockName() != null ? (" (on " + ti.getLockName() + " owned by " + ti.getLockOwnerId() + ")") : ""));
    if (ti.isSuspended()) {
        System.out.println("   SUSPENDED");
    }
    if (ti.isInNative()) {
        System.out.println("   IN NATIVE CODE");
    }
    for (final StackTraceElement ste : ti.getStackTrace()) {
        System.out.println("      " + ste.toString());
    }
}
 
Example 15
Source File: CrossedStealingDeadlockIT.java    From offheap-store with Apache License 2.0 5 votes vote down vote up
private static String dumpThread(ThreadInfo thread) {
  StringBuilder sb = new StringBuilder("\"" + thread.getThreadName() + "\"" +
                                       " Id=" + thread.getThreadId() + " " +
                                       thread.getThreadState());
  if (thread.getLockName() != null) {
      sb.append(" on " + thread.getLockName());
  }
  if (thread.getLockOwnerName() != null) {
      sb.append(" owned by \"" + thread.getLockOwnerName() +
                "\" Id=" + thread.getLockOwnerId());
  }
  if (thread.isSuspended()) {
      sb.append(" (suspended)");
  }
  if (thread.isInNative()) {
      sb.append(" (in native)");
  }
  sb.append('\n');

  StackTraceElement[] trace = thread.getStackTrace();
  for (StackTraceElement ste : trace) {
    sb.append("\tat " + ste.toString());
    sb.append('\n');
  }
  sb.append('\n');
  return sb.toString();
}
 
Example 16
Source File: OSProcess.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
private static void formatThreadInfo(ThreadInfo t, PrintWriter pw) {
    // this is largely copied from the JDK's ThreadInfo.java, but it limits the
    // stacks to 8 elements
    pw.append("\"" + t.getThreadName() + "\"" +
        " tid=0x" + Long.toHexString(t.getThreadId()));
// this is in the stack trace elements so we don't need to add it
//    if (t.getLockName() != null) {
//      pw.append(" ");
//      pw.append(StringUtils.toLowerCase(t.getThreadState().toString()));
//      pw.append(" on " + t.getLockName());
//    }
    // priority is not known
    // daemon status is not known
    if (t.isSuspended()) {
      pw.append(" (suspended)");
    }
    if (t.isInNative()) {
      pw.append(" (in native)");
    }
    if (t.getLockOwnerName() != null) {
      pw.append(" owned by \"" + t.getLockOwnerName() +
          "\" tid=0x" + Long.toHexString(t.getLockOwnerId()));
    }
    pw.append('\n');
    pw.append("    java.lang.Thread.State: " + t.getThreadState() + "\n");
    int i = 0;
    StackTraceElement[] stackTrace = t.getStackTrace();
    for (; i < stackTrace.length && i < MAX_STACK_FRAMES; i++) {
      StackTraceElement ste = stackTrace[i];
      pw.append("\tat " + ste.toString());
      pw.append('\n');
      if (i == 0 && t.getLockInfo() != null) {
        Thread.State ts = t.getThreadState();
        switch (ts) {
        case BLOCKED: 
          pw.append("\t-  blocked on " + t.getLockInfo());
          pw.append('\n');
          break;
        case WAITING:
          pw.append("\t-  waiting on " + t.getLockInfo());
          pw.append('\n');
          break;
        case TIMED_WAITING:
          pw.append("\t-  waiting on " + t.getLockInfo());
          pw.append('\n');
          break;
        default:
        }
      }

      for (MonitorInfo mi : t.getLockedMonitors()) {
        if (mi.getLockedStackDepth() == i) {
          pw.append("\t-  locked " + mi);
          pw.append('\n');
        }
      }
    }
    if (i < stackTrace.length) {
      pw.append("\t...");
      pw.append('\n');
    }

    LockInfo[] locks = t.getLockedSynchronizers();
    if (locks.length > 0) {
      pw.append("\n\tNumber of locked synchronizers = " + locks.length);
      pw.append('\n');
      for (LockInfo li : locks) {
        pw.append("\t- " + li);
        pw.append('\n');
      }
    }
    pw.append('\n');
  }
 
Example 17
Source File: SdcInfoContentGenerator.java    From datacollector with Apache License 2.0 4 votes vote down vote up
public void threadDump(BundleWriter writer) throws IOException {
  writer.markStartOfFile("runtime/threads.txt");

  ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
  ThreadInfo[] threads = threadMXBean.dumpAllThreads(true, true);

  // Sadly we can't easily do info.toString() as the implementation is hardcoded to cut the stack trace only to 8
  // items which does not serve our purpose well. Hence we have custom implementation that prints entire stack trace
  // for all threads.
  for(ThreadInfo info: threads) {
    StringBuilder sb = new StringBuilder("\"" + info.getThreadName() + "\"" + " Id=" + info.getThreadId() + " " + info.getThreadState());
    if (info.getLockName() != null) {
      sb.append(" on " + info.getLockName());
    }
    if (info.getLockOwnerName() != null) {
      sb.append(" owned by \"" + info.getLockOwnerName() + "\" Id=" + info.getLockOwnerId());
    }
    if (info.isSuspended()) {
      sb.append(" (suspended)");
    }
    if (info.isInNative()) {
      sb.append(" (in native)");
    }
    sb.append('\n');
    int i = 0;
    for(StackTraceElement ste : info.getStackTrace()) {
      if (i == 0 && info.getLockInfo() != null) {
        Thread.State ts = info.getThreadState();
        switch (ts) {
          case BLOCKED:
            sb.append("\t-  blocked on " + info.getLockInfo());
            sb.append('\n');
            break;
          case WAITING:
            sb.append("\t-  waiting on " + info.getLockInfo());
            sb.append('\n');
            break;
          case TIMED_WAITING:
            sb.append("\t-  waiting on " + info.getLockInfo());
            sb.append('\n');
            break;
          default:
        }
      }
      sb.append("\tat " + ste.toString());
      sb.append('\n');

      i++;

      for (MonitorInfo mi : info.getLockedMonitors()) {
        if (mi.getLockedStackDepth() == i) {
          sb.append("\t-  locked " + mi);
          sb.append('\n');
        }
      }
    }

    LockInfo[] locks = info.getLockedSynchronizers();
    if (locks.length > 0) {
      sb.append("\n\tNumber of locked synchronizers = " + locks.length);
      sb.append('\n');
      for (LockInfo li : locks) {
        sb.append("\t- " + li);
        sb.append('\n');
      }
    }
    sb.append('\n');

    writer.write(sb.toString());
  }

  writer.markEndOfFile();
}
 
Example 18
Source File: ThreadMXBeanStateTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void checkLockInfo(ThreadStateController t, Thread.State state,
                                  Object lock, Thread owner) {
    ThreadInfo info = getThreadInfo(t, state);
    if (info == null) {
        throw new RuntimeException(t.getName() +
           " expected to have ThreadInfo " +
           " but got null.");
    }

    if (info.getThreadState() != state) {
        throw new RuntimeException(t.getName() + " expected to be in " +
            state + " state but got " + info.getThreadState());
    }

    if (lock == null && info.getLockName() != null) {
        throw new RuntimeException(t.getName() +
            " expected not to be blocked on any lock" +
            " but got " + info.getLockName());
    }
    String expectedLockName = getLockName(lock);
    if (lock != null && info.getLockName() == null) {
        throw new RuntimeException(t.getName() +
            " expected to be blocked on lock [" + expectedLockName +
            "] but got null.");
    }

    if (lock != null && !expectedLockName.equals(info.getLockName())) {
        throw new RuntimeException(t.getName() +
            " expected to be blocked on lock [" + expectedLockName +
            "] but got [" + info.getLockName() + "].");
    }

    if (owner == null && info.getLockOwnerName() != null) {
        throw new RuntimeException("Lock owner is expected " +
            " to be null but got " + info.getLockOwnerName());
    }

    if (owner != null && info.getLockOwnerName() == null) {
        throw new RuntimeException("Lock owner is expected to be " +
            owner.getName() +
            " but got null.");
    }
    if (owner != null && !info.getLockOwnerName().equals(owner.getName())) {
        throw new RuntimeException("Lock owner is expected to be " +
            owner.getName() +
            " but got " + owner.getName());
    }
    if (owner == null && info.getLockOwnerId() != -1) {
        throw new RuntimeException("Lock owner is expected " +
            " to be -1 but got " + info.getLockOwnerId());
    }

    if (owner != null && info.getLockOwnerId() <= 0) {
        throw new RuntimeException("Lock owner is expected to be " +
            owner.getName() + "(id = " + owner.getId() +
            ") but got " + info.getLockOwnerId());
    }
    if (owner != null && info.getLockOwnerId() != owner.getId()) {
        throw new RuntimeException("Lock owner is expected to be " +
            owner.getName() + "(id = " + owner.getId() +
            ") but got " + info.getLockOwnerId());
    }
    if (info.isSuspended()) {
        throw new RuntimeException(t.getName() +
            " isSuspended() returns " + info.isSuspended());
    }
}
 
Example 19
Source File: ThreadMXBeanStateTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void checkLockInfo(ThreadStateController t, Thread.State state,
                                  Object lock, Thread owner) {
    ThreadInfo info = getThreadInfo(t, state);
    if (info == null) {
        throw new RuntimeException(t.getName() +
           " expected to have ThreadInfo " +
           " but got null.");
    }

    if (info.getThreadState() != state) {
        throw new RuntimeException(t.getName() + " expected to be in " +
            state + " state but got " + info.getThreadState());
    }

    if (lock == null && info.getLockName() != null) {
        throw new RuntimeException(t.getName() +
            " expected not to be blocked on any lock" +
            " but got " + info.getLockName());
    }
    String expectedLockName = getLockName(lock);
    if (lock != null && info.getLockName() == null) {
        throw new RuntimeException(t.getName() +
            " expected to be blocked on lock [" + expectedLockName +
            "] but got null.");
    }

    if (lock != null && !expectedLockName.equals(info.getLockName())) {
        throw new RuntimeException(t.getName() +
            " expected to be blocked on lock [" + expectedLockName +
            "] but got [" + info.getLockName() + "].");
    }

    if (owner == null && info.getLockOwnerName() != null) {
        throw new RuntimeException("Lock owner is expected " +
            " to be null but got " + info.getLockOwnerName());
    }

    if (owner != null && info.getLockOwnerName() == null) {
        throw new RuntimeException("Lock owner is expected to be " +
            owner.getName() +
            " but got null.");
    }
    if (owner != null && !info.getLockOwnerName().equals(owner.getName())) {
        throw new RuntimeException("Lock owner is expected to be " +
            owner.getName() +
            " but got " + owner.getName());
    }
    if (owner == null && info.getLockOwnerId() != -1) {
        throw new RuntimeException("Lock owner is expected " +
            " to be -1 but got " + info.getLockOwnerId());
    }

    if (owner != null && info.getLockOwnerId() <= 0) {
        throw new RuntimeException("Lock owner is expected to be " +
            owner.getName() + "(id = " + owner.getId() +
            ") but got " + info.getLockOwnerId());
    }
    if (owner != null && info.getLockOwnerId() != owner.getId()) {
        throw new RuntimeException("Lock owner is expected to be " +
            owner.getName() + "(id = " + owner.getId() +
            ") but got " + info.getLockOwnerId());
    }
    if (info.isSuspended()) {
        throw new RuntimeException(t.getName() +
            " isSuspended() returns " + info.isSuspended());
    }
}
 
Example 20
Source File: JVMUtil.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
private static String getThreadDumpString(ThreadInfo threadInfo) {
    StringBuilder sb = new StringBuilder("\"" + threadInfo.getThreadName() + "\"" +
            " Id=" + threadInfo.getThreadId() + " " +
            threadInfo.getThreadState());
    if (threadInfo.getLockName() != null) {
        sb.append(" on " + threadInfo.getLockName());
    }
    if (threadInfo.getLockOwnerName() != null) {
        sb.append(" owned by \"" + threadInfo.getLockOwnerName() +
                "\" Id=" + threadInfo.getLockOwnerId());
    }
    if (threadInfo.isSuspended()) {
        sb.append(" (suspended)");
    }
    if (threadInfo.isInNative()) {
        sb.append(" (in native)");
    }
    sb.append('\n');
    int i = 0;

    StackTraceElement[] stackTrace = threadInfo.getStackTrace();
    MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors();
    for (; i < stackTrace.length && i < 32; i++) {
        StackTraceElement ste = stackTrace[i];
        sb.append("\tat " + ste.toString());
        sb.append('\n');
        if (i == 0 && threadInfo.getLockInfo() != null) {
            Thread.State ts = threadInfo.getThreadState();
            switch (ts) {
                case BLOCKED:
                    sb.append("\t-  blocked on " + threadInfo.getLockInfo());
                    sb.append('\n');
                    break;
                case WAITING:
                    sb.append("\t-  waiting on " + threadInfo.getLockInfo());
                    sb.append('\n');
                    break;
                case TIMED_WAITING:
                    sb.append("\t-  waiting on " + threadInfo.getLockInfo());
                    sb.append('\n');
                    break;
                default:
            }
        }

        for (MonitorInfo mi : lockedMonitors) {
            if (mi.getLockedStackDepth() == i) {
                sb.append("\t-  locked " + mi);
                sb.append('\n');
            }
        }
    }
    if (i < stackTrace.length) {
        sb.append("\t...");
        sb.append('\n');
    }

    LockInfo[] locks = threadInfo.getLockedSynchronizers();
    if (locks.length > 0) {
        sb.append("\n\tNumber of locked synchronizers = " + locks.length);
        sb.append('\n');
        for (LockInfo li : locks) {
            sb.append("\t- " + li);
            sb.append('\n');
        }
    }
    sb.append('\n');
    return sb.toString();
}