code: public static ThreadGroup getSystemThreadGroup() {
          ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
          while(threadGroup.getParent() != null) {
              threadGroup = threadGroup.getParent();
          }
          return threadGroup;
      }
docs: Return the system thread group (sometimes also referred as "root thread group").
  
  @return the system thread group
  @throws  SecurityException  if the current thread cannot modify
  thread groups from this thread's thread group up to the system thread group