code: public static String getFormattedThreadList(
        final String prefix, final String threadPrefix, final String stackElementPrefix) {
  
      // Sort by thread name
      final TreeMap<String, StackTraceElement[]> threadNames = new TreeMap<>();
      for (final Map.Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) {
  
        final Thread t = entry.getKey();
        final String tg = t.getThreadGroup() == null ? null : t.getThreadGroup().getName();
  
        if (!"system".equals(tg)) {
          threadNames.put(String.format("TG %s THREAD %s :: %s, %s, %s, %s",
              tg, t.getName(), t.getState(),
              t.isAlive() ? "Alive" : "NOT alive",
              t.isInterrupted() ? "Interrupted" : "NOT interrupted",
              t.isDaemon() ? "Daemon" : "NOT daemon"), entry.getValue());
        }
      }
  
      final StringBuilder message = new StringBuilder(prefix);
      for (final Map.Entry<String, StackTraceElement[]> entry : threadNames.entrySet()) {
        message.append(threadPrefix).append(entry.getKey());
        for (final StackTraceElement element : entry.getValue()) {
          message.append(stackElementPrefix).append(element);
        }
      }
  
      return message.toString();
    }
docs: Produces a String representation of the currently running threads.
  
  @param prefix             The prefix of the string returned.
  @param threadPrefix       Printed before each thread, e.g. "\n\t" to create an indented list.
  @param stackElementPrefix Printed before each stack trace element, e.g. "\n\t\t" to create an indented list.
  @return a String representation of the currently running threads.