Java Code Examples for java.lang.management.MonitorInfo

The following examples show how to use java.lang.management.MonitorInfo. These examples are extracted from open source projects. 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
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();
}
 
Example 2
Source Project: Nukkit   Source File: Watchdog.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static void dumpThread(ThreadInfo thread, Logger logger) {
    logger.emergency("Current Thread: " + thread.getThreadName());
    logger.emergency("\tPID: " + thread.getThreadId() + " | Suspended: " + thread.isSuspended() + " | Native: " + thread.isInNative() + " | State: " + thread.getThreadState());
    // Monitors
    if (thread.getLockedMonitors().length != 0) {
        logger.emergency("\tThread is waiting on monitor(s):");
        for (MonitorInfo monitor : thread.getLockedMonitors()) {
            logger.emergency("\t\tLocked on:" + monitor.getLockedStackFrame());
        }
    }

    logger.emergency("\tStack:");
    for (StackTraceElement stack : thread.getStackTrace()) {
        logger.emergency("\t\t" + stack);
    }
}
 
Example 3
Source Project: Kettle   Source File: WatchdogThread.java    License: GNU General Public License v3.0 6 votes vote down vote up
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);
    }
}
 
Example 4
Source Project: tda   Source File: MBeanDumper.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
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");
}
 
Example 5
Source Project: netbeans   Source File: Detector.java    License: Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 6
Source Project: netbeans   Source File: NbTestCase.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 7
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();
}
 
Example 8
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();
}
 
Example 9
Source Project: jdk8u-dev-jdk   Source File: ThreadMonitor.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 10
Source Project: mapleLemon   Source File: DeadlockDetector.java    License: GNU General Public License v2.0 6 votes vote down vote up
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");
            }
        }
    }
}
 
Example 11
Source Project: hadoop   Source File: TimedOutTestsListener.java    License: Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 12
Source Project: jdk8u-jdk   Source File: ThreadMonitor.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 13
Source Project: distributedlog   Source File: TimedOutTestsListener.java    License: Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 14
Source Project: jdk8u-jdk   Source File: MappedMXBeanType.java    License: GNU General Public License v2.0 5 votes vote down vote up
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example 15
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example 16
public MonitorInfo[] lockedMonitors() {
    CompositeData[] lockedMonitorsData =
        (CompositeData[]) cdata.get(LOCKED_MONITORS);

    // The LockedMonitors item cannot be null, but if it is we will get
    // a NullPointerException when we ask for its length.
    MonitorInfo[] monitors =
        new MonitorInfo[lockedMonitorsData.length];
    for (int i = 0; i < lockedMonitorsData.length; i++) {
        CompositeData cdi = lockedMonitorsData[i];
        monitors[i] = MonitorInfo.from(cdi);
    }
    return monitors;
}
 
Example 17
Source Project: tda   Source File: MBeanDumper.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti, MonitorInfo[] monitors, StringBuilder dump) {
   dump.append(INDENT + "Locked monitors: count = " + monitors.length);
    for (int j = 0; j < monitors.length; j++) {
        MonitorInfo mi = monitors[j];
        dump.append(INDENT + "  - " + mi + " locked at \n");
        
        dump.append(INDENT + "      " + mi.getLockedStackDepth() +
                                              " " + mi.getLockedStackFrame());
        dump.append("\n");
   }
}
 
Example 18
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example 19
Source Project: visualvm   Source File: ThreadDumpWindow.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void printMonitors(final StringBuilder sb, final MonitorInfo[] monitors, final int index) {
    if (monitors != null) {
        for (MonitorInfo mi : monitors) {
            if (mi.getLockedStackDepth() == index) {
                sb.append("    - locked ");   // NOI18N
                printLock(sb, mi);
                sb.append("<br>");    // NOI18N
            }
        }
    }
}
 
Example 20
Object toOpenTypeData(Object data) throws OpenDataException {
    if (data instanceof MemoryUsage) {
        return MemoryUsageCompositeData.toCompositeData((MemoryUsage) data);
    }

    if (data instanceof ThreadInfo) {
        return ThreadInfoCompositeData.toCompositeData((ThreadInfo) data);
    }

    if (data instanceof LockInfo) {
        if (data instanceof java.lang.management.MonitorInfo) {
            return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
        }
        return LockInfoCompositeData.toCompositeData((LockInfo) data);
    }

    if (data instanceof MemoryNotificationInfo) {
        return MemoryNotifInfoCompositeData.
            toCompositeData((MemoryNotificationInfo) data);
    }

    if (data instanceof VMOption) {
        return VMOptionCompositeData.toCompositeData((VMOption) data);
    }

    if (isCompositeData) {
        // Classes that implement CompositeData
        //
        // construct a new CompositeDataSupport object
        // so that no other classes are sent over the wire
        CompositeData cd = (CompositeData) data;
        CompositeType ct = cd.getCompositeType();
        String[] itemNames = ct.keySet().toArray(new String[0]);
        Object[] itemValues = cd.getAll(itemNames);
        return new CompositeDataSupport(ct, itemNames, itemValues);
    }

    throw new OpenDataException(javaClass.getName() +
        " is not supported for platform MXBeans");
}
 
Example 21
public MonitorInfo[] lockedMonitors() {
    CompositeData[] lockedMonitorsData =
        (CompositeData[]) cdata.get(LOCKED_MONITORS);

    // The LockedMonitors item cannot be null, but if it is we will get
    // a NullPointerException when we ask for its length.
    MonitorInfo[] monitors =
        new MonitorInfo[lockedMonitorsData.length];
    for (int i = 0; i < lockedMonitorsData.length; i++) {
        CompositeData cdi = lockedMonitorsData[i];
        monitors[i] = MonitorInfo.from(cdi);
    }
    return monitors;
}
 
Example 22
Source Project: swift-k   Source File: HangChecker.java    License: Apache License 2.0 5 votes vote down vote up
private void printThreadInfo(PrintStream pw, ThreadInfo ti) {
    pw.println("\tThread \"" + ti.getThreadName() + "\" (" + hex(ti.getThreadId()) + ") " + ti.getThreadState());
    LockInfo l = ti.getLockInfo();
    if (l != null) {
        pw.println("\t\twaiting for " + format(l) + 
                (ti.getLockOwnerName() == null ? "" : " held by " + ti.getLockOwnerName() + " (" + hex(ti.getLockOwnerId()) + ")"));
    }
    Map<StackTraceElement, MonitorInfo> mlocs = new HashMap<StackTraceElement, MonitorInfo>();
    MonitorInfo[] mis = ti.getLockedMonitors();
    if (mis.length > 0) {
        pw.println("\tMonitors held:");
        for (MonitorInfo mi : mis) {
            mlocs.put(mi.getLockedStackFrame(), mi);
            pw.println("\t\t" + format(mi));
        }
    }
    LockInfo[] lis = ti.getLockedSynchronizers();
    if (lis.length > 0) {
        pw.println("\tSynchronizers held:");
        for (LockInfo li : lis) {
            pw.println("\t\t" + format(li));
        }
    }
    pw.println("\tStack trace:");
    StackTraceElement[] stes = ti.getStackTrace();
    for (StackTraceElement ste : stes) {
        pw.print("\t\t" + ste.getClassName() + "." + ste.getMethodName() + formatLineNumber(":", ste.getLineNumber()));
        if (mlocs.containsKey(ste)) {
            pw.print(" -> locked " + format(mlocs.get(ste)));
        }
        pw.println();
    }
    pw.println();
}
 
Example 23
public MonitorInfo[] lockedMonitors() {
    CompositeData[] lockedMonitorsData =
        (CompositeData[]) cdata.get(LOCKED_MONITORS);

    // The LockedMonitors item cannot be null, but if it is we will get
    // a NullPointerException when we ask for its length.
    MonitorInfo[] monitors =
        new MonitorInfo[lockedMonitorsData.length];
    for (int i = 0; i < lockedMonitorsData.length; i++) {
        CompositeData cdi = lockedMonitorsData[i];
        monitors[i] = MonitorInfo.from(cdi);
    }
    return monitors;
}
 
Example 24
Source Project: jdk8u60   Source File: ThreadMonitor.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}
 
Example 25
public MonitorInfo[] lockedMonitors() {
    CompositeData[] lockedMonitorsData =
        (CompositeData[]) cdata.get(LOCKED_MONITORS);

    // The LockedMonitors item cannot be null, but if it is we will get
    // a NullPointerException when we ask for its length.
    MonitorInfo[] monitors =
        new MonitorInfo[lockedMonitorsData.length];
    for (int i = 0; i < lockedMonitorsData.length; i++) {
        CompositeData cdi = lockedMonitorsData[i];
        monitors[i] = MonitorInfo.from(cdi);
    }
    return monitors;
}
 
Example 26
Source Project: jdk8u-jdk   Source File: ThreadMonitor.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}
 
Example 27
public MonitorInfo[] lockedMonitors() {
    CompositeData[] lockedMonitorsData =
        (CompositeData[]) cdata.get(LOCKED_MONITORS);

    // The LockedMonitors item cannot be null, but if it is we will get
    // a NullPointerException when we ask for its length.
    MonitorInfo[] monitors =
        new MonitorInfo[lockedMonitorsData.length];
    for (int i = 0; i < lockedMonitorsData.length; i++) {
        CompositeData cdi = lockedMonitorsData[i];
        monitors[i] = MonitorInfo.from(cdi);
    }
    return monitors;
}
 
Example 28
Source Project: openjdk-jdk8u   Source File: ThreadMonitor.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}
 
Example 29
Source Project: dsl-devkit   Source File: TestRunRecording.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Prints the owned locks for the thread.
 * Must have explicitly obtained Monitor and Synchronizer information for anything to show up from here.
 *
 * @param info
 *          the {@code:ThreadInfo} for the thread in question, must not be {@code:null}
 * @return the owned lock information
 */
private static String getOwnedLockInfo(final ThreadInfo info) {
  StringBuilder trace = new StringBuilder("  Holding locks for:\r\n");
  for (LockInfo lock : info.getLockedSynchronizers()) {
    trace.append("    " + lock.toString() + "\r\n");
  }
  for (MonitorInfo monitor : info.getLockedMonitors()) {
    trace.append("    " + monitor.toString() + "\r\n");
  }
  return trace.toString();
}
 
Example 30
Source Project: openjdk-8   Source File: ThreadMonitor.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void printMonitorInfo(ThreadInfo ti) {
   MonitorInfo[] monitors = ti.getLockedMonitors();
   System.out.println(INDENT + "Locked monitors: count = " + monitors.length);
   for (MonitorInfo mi : monitors) {
       System.out.println(INDENT + "  - " + mi + " locked at ");
       System.out.println(INDENT + "      " + mi.getLockedStackDepth() +
                          " " + mi.getLockedStackFrame());
   }
}