It might be useful to garner an enumeration of all thread groups and theirthreads in your running application. The following method shows you how todo that:
public void printOutThreadGroups(){ //create a thread Thread t = new Thread(); //get the current thread Thread tt = t.currentThread(); //get the thread group of current thread ThreadGroup tg = tt.getThreadGroup(); ThreadGroup topMost = null; //find the topmost thread group while(tg != null) { topMost = tg; tg = tg.getParent(); } //get an estimate of active thread groups under topMost int groupCount = topMost.activeGroupCount(); //get an enumeration of thread groups under topMost ThreadGroup[] tgArray = new ThreadGroup[groupCount]; topMost.enumerate(tgArray, true); //for every thread group under topMost, print out the
active threads System.out.println("Top Most ThreadGroup: ""+topMost.getName()+ "" has the following Thread Groups:"); System.out.println("**********************"); for(int i=0; i