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());
    }
  }
JUnit run listener which prints full thread dump into System.err in case a test is failed due to
timeout.
hbase-common/src/test/java/org/apache/hadoop/hbase/TimedOutTestsListener.java