示例#1
0
 public static void dumptg(ThreadGroup tg, PrintWriter out) {
   if (tg == null) {
     tg = Thread.currentThread().getThreadGroup();
     while (tg.getParent() != null) tg = tg.getParent();
   }
   dumptg(tg, out, 0);
   out.flush();
 }
示例#2
0
 private static void dumptg(ThreadGroup tg, PrintWriter out, int indent) {
   for (int o = 0; o < indent; o++) out.print("\t");
   out.println("G: \"" + tg.getName() + "\"");
   Thread[] ths = new Thread[tg.activeCount() * 2];
   ThreadGroup[] tgs = new ThreadGroup[tg.activeGroupCount() * 2];
   int nt = tg.enumerate(ths, false);
   int ng = tg.enumerate(tgs, false);
   for (int i = 0; i < nt; i++) {
     Thread ct = ths[i];
     for (int o = 0; o < indent + 1; o++) out.print("\t");
     out.println("T: \"" + ct.getName() + "\"");
   }
   for (int i = 0; i < ng; i++) {
     ThreadGroup cg = tgs[i];
     dumptg(cg, out, indent + 1);
   }
 }