code: @edu.umd.cs.findbugs.annotations.SuppressWarnings(
              value = {"VA_FORMAT_STRING_USES_NEWLINE"},
              justification = "We don't want platform specific"
      )
      public static void threadDump(OutputStream out) throws UnsupportedEncodingException {
          final PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, "utf-8"), true);
  
          ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
          ThreadInfo[] threads;
          try {
              threads = mbean.dumpAllThreads(mbean.isObjectMonitorUsageSupported(), mbean.isSynchronizerUsageSupported());
          } catch (UnsupportedOperationException x) {
              SupportLogFormatter.printStackTrace(x, writer);
              threads = new ThreadInfo[0];
          }
  
          Arrays.sort(threads, new Comparator<ThreadInfo>() {
              @Override
              public int compare(ThreadInfo t1, ThreadInfo t2) {
                  return t1.getThreadName().compareTo(t2.getThreadName());
              }
          });
          for (ThreadInfo t : threads) {
              printThreadInfo(writer, t, mbean);
          }
  
          // Print any information about deadlocks.
          long[] deadLocks;
          try {
              deadLocks = mbean.findDeadlockedThreads();
          } catch (UnsupportedOperationException x) {
              SupportLogFormatter.printStackTrace(x, writer);
              deadLocks = null;
          }
          if (deadLocks != null && deadLocks.length != 0) {
              writer.println(" Deadlock Found ");
              ThreadInfo[] deadLockThreads = mbean.getThreadInfo(deadLocks);
              for (ThreadInfo threadInfo : deadLockThreads) {
                  StackTraceElement[] elements = threadInfo.getStackTrace();
                  for (StackTraceElement element : elements) {
                      writer.println(element.toString());
                  }
              }
          }
  
          writer.println();
          writer.flush();
      }
docs: Dumps all of the threads' current information to an output stream.
  
  @param out an output stream.
  @throws UnsupportedEncodingException if the utf-8 encoding is not supported.