code: private static void printGroupInfo(final PrintWriter out, final ThreadGroup group, final String indent) {
          if (group == null) {
              return;
          }
  
          final int numThreads = group.activeCount();
          final int numGroups = group.activeGroupCount();
          final Thread[] threads = new Thread[numThreads];
          final ThreadGroup[] groups = new ThreadGroup[numGroups];
          group.enumerate(threads, false);
          group.enumerate(groups, false);
          out.println(indent + "Thread Group: " + group.getName() + "  Max Priority: " + group.getMaxPriority() + (group.isDaemon() ? " Daemon" : ""));
  
          for (int i = 0; i < numThreads; i++) {
              Util.printThreadInfo(out, threads[i], indent + "    ");
          }
  
          for (int i = 0; i < numGroups; i++) {
              Util.printGroupInfo(out, groups[i], indent + "    ");
          }
      }
docs: Display info about a thread group and its threads and groups