code: private static String getThreadInfo(Thread thread) {
      final StringBuilder sb = new StringBuilder();
  
      sb.append("Thread:     ");
      sb.append(thread.getId());
      sb.append(" (");
      sb.append(thread.getName());
      sb.append(")");
      sb.append(lineSeparator);
      final StackTraceElement[] stack = thread.getStackTrace();
      if (stack.length == 0) {
        sb.append("        No Java callstack associated with this thread");
        sb.append(lineSeparator);
      } else {
        for (StackTraceElement element : stack) {
          sb.append("        at ");
          sb.append(element.getClassName());
          sb.append(".");
          sb.append(element.getMethodName());
          sb.append("(");
          final int lineNumber = element.getLineNumber();
          if (lineNumber == -2) {
            sb.append("Native Method");
          } else if (lineNumber >=0) {
            sb.append(element.getFileName());
            sb.append(":");
            sb.append(element.getLineNumber());
          } else {
            sb.append(element.getFileName());
          }
          sb.append(")");
          sb.append(lineSeparator);
        }
      }
      sb.append(lineSeparator);
  
      return sb.toString();
    }
docs: Gets and formats the specified thread's information.
  
  @param thread The thread to obtain the information from.
  @return A formatted string for the thread information.