Source Code : Listing All Running Threads in a group
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Listing All Running Threads in a group
public class Main {
public static void main(String[] argv) throws Exception {
ThreadGroup group = Thread.currentThread().getThreadGroup().getParent();
while (group.getParent() != null) {
group = group.getParent();
}
int numThreads = group.activeCount();
Thread[] threads = new Thread[numThreads * 2];
numThreads = group.enumerate(threads, false);
for (int i = 0; i < numThreads; i++) {
Thread thread = threads[i];
System.out.println(thread.getName());
}
int numGroups = group.activeGroupCount();
ThreadGroup[] groups = new ThreadGroup[numGroups * 2];
numGroups = group.enumerate(groups, false);
for (int i = 0; i < numGroups; i++) {
System.out.println(groups[i]);
}
}
}
Thank with us