Search

Loading
Showing posts with label threads. Show all posts
Showing posts with label threads. Show all posts

Wednesday, June 13, 2012

How to get List of Java Threads

The following code returns a list of Java Threads :
package ListThreads;

import java.util.Set;

public class ListOfThreads {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Set threadSet = Thread.getAllStackTraces().keySet();
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
for(int i=0;i
System.out.println(threadArray[i].getName().toString());
}
}
}
Original Article : http://developerpages.gr/index.php/el/desktop-development-2/java/47-how-to-get-list-of-java-threads