Este snippet es una utilidad bastante interesante en lo que respecta a Java Debugging. Mediante codigo que podes colocar en tu software podes ver los Threads activos dentro de la JVM.

Primero tenemos un metodo que va a ser el trigger llamando recursivamente a un visitor pattern.

public void showActiveThreads() {
  // Find the root thread group
  ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
    while (root.getParent() != null) {
    root = root.getParent();
  }    
  // Visit each thread group
  visit(root, 0);
}

Ahora el principal metodo donde se imprimen los threads.

private void visit(ThreadGroup group, int level) {
  // Get threads in the group
  int numThreads = group.activeCount();
  Thread[] threads = new Thread[numThreads * 2];
  numThreads = group.enumerate(threads, false);

  // Enumerate each thread in the group
  for (int i = 0; i < numThreads; i  ) {
    // Get thread
    Thread thread = threads[i];
    System.out.println("Thread Name: "   thread.getName());
  }

  // Get thread subgroups of group
  int numGroups = group.activeGroupCount();
  ThreadGroup[] groups = new ThreadGroup[numGroups * 2];
  numGroups = group.enumerate(groups, false);

  // Recursively visit each subgroup
  for (int i = 0; i < numGroups; i  ) {
    visit(groups[i], level   1);
  }
}