Αναζήτηση

Saturday, May 12, 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

No comments:

Post a Comment