WAP to display all active Thread names belongs to System Group and Child Class


public class ThreadGroupExamp {

    public static void main(String[] args) {

        ThreadGroup system = Thread.currentThread().getThreadGroup();
        Thread[] threads = new Thread[system.activeCount()];
        system.enumerate(threads);
        for(Thread t:threads){
            if (t != null && t.getThreadGroup() == system) {
                System.out.println("Thread Name: " + t.getName());
            }
        }
  
 }
}
WAP to display all active Thread names belongs to System Group and Child Class

Leave a Comment