public static ThreadGroup getRootThreadGroup() { if (rootThreadGroup != null) return rootThreadGroup; ThreadGroup tg = Thread.currentThread().getThreadGroup(); ThreadGroup ptg; while ((ptg = tg.getParent()) != null) tg = ptg; return tg; }