code: public static ThreadGroup findRootThreadGroup()
      {
          ThreadGroup root = Thread.currentThread().getThreadGroup();
          while (root.getParent() != null) {
              root = root.getParent();
          }
          return root;
      }
docs: Find the root thread group.
  @return