public int activeCount ( ) { int result ; // Snapshot sub-group data so we don't hold this lock // while our children are computing. int ngroupsSnapshot ; ThreadGroup [ ] groupsSnapshot ; synchronized ( this ) { if ( destroyed ) { return 0 ; } result = nthreads ; ngroupsSnapshot = ngroups ; if ( groups != null ) { groupsSnapshot = Arrays . copyOf ( groups , ngroupsSnapshot ) ; } else { groupsSnapshot = null ; } } for ( int i = 0 ; i < ngroupsSnapshot ; i ++ ) { result += groupsSnapshot [ i ] . activeCount ( ) ; } return result ; }
Returns an estimate of the number of active threads in this thread group and its subgroups . Recursively iterates over all subgroups in this thread group .