code: void threadTerminated(Thread t) {
          synchronized (this) {
              remove(t);
  
              if (nthreads == 0) {
                  notifyAll();
              }
              if (daemon && (nthreads == 0) &&
                  (nUnstartedThreads == 0) && (ngroups == 0))
              {
                  destroy();
              }
          }
      }
docs: Notifies the group that the thread {@code t} has terminated.
  
  <p> Destroy the group if all of the following conditions are
  true: this is a daemon thread group; there are no more alive
  or unstarted threads in the group; there are no subgroups in
  this thread group.
  
  @param  t
  the Thread that has terminated