I want to know how many active threads are there for a particular Thread class. Lets say I have a class T which extends thread. In some other class (Ex: Demo) , I want to get t
You can use Thread.enumerate():
Thread.enumerate()
public int countThreadsOfClass(Class extends Thread> clazz) { Thread[] tarray = new Thread[Thread.activeCount()]; Thread.enumerate(tarray); int count = 0; for(Thread t : tarray) { if(clazz.isInstance(t)) count++; } return count; }