code: public int activeGroupCount() {
          int ngroupsSnapshot;
          ThreadGroup[] groupsSnapshot;
          synchronized (this) {
              if (destroyed) {
                  return 0;
              }
              ngroupsSnapshot = ngroups;
              if (groups != null) {
                  groupsSnapshot = Arrays.copyOf(groups, ngroupsSnapshot);
              } else {
                  groupsSnapshot = null;
              }
          }
          int n = ngroupsSnapshot;
          for (int i = 0 ; i < ngroupsSnapshot ; i++) {
              n += groupsSnapshot[i].activeGroupCount();
          }
          return n;
      }
docs: Returns an estimate of the number of active groups in this
  thread group and its subgroups. Recursively iterates over
  all subgroups in this thread group.
  
  <p> The value returned is only an estimate because the number of
  thread groups may change dynamically while this method traverses
  internal data structures. This method is intended primarily for
  debugging and monitoring purposes.
  
  @return  the number of active thread groups with this thread group as
  an ancestor
  
  @since   JDK1.0