code: private List<Thread> getThreadsInGroup(ThreadGroup group) {
          final int activeThreadCount = group.activeCount(); // this is just an estimate
          int threadArraySize = Math.max(activeThreadCount * 2, 100);
          for (int loopCount = 0; loopCount < 5; loopCount++) {
              Thread[] threads = new Thread[threadArraySize];
              int enumCount = group.enumerate(threads);
              if (enumCount < threadArraySize) {
                  return Arrays.asList(threads).subList(0, enumCount);
              }
              // if there are too many threads to fit into the array, enumerate's result
              // is >= the array's length; therefore we can't trust that it returned all
              // the threads.  Try again.
              threadArraySize += 100;
          }
          // threads are proliferating too fast for us.  Bail before we get into 
          // trouble.
          return Collections.emptyList();
      }
docs: Returns all active threads belonging to a thread group.
  @param group The thread group.
  @return The active threads in the thread group.  The result should be a
  complete list of the active threads at some point in time.  Returns an empty list
  if this cannot be determined, e.g. because new threads are being created at an
  extremely fast rate.