Created
March 30, 2015 05:07
-
-
Save rajivrnair/48a742ce632caab3f9a5 to your computer and use it in GitHub Desktop.
Print information about currently running threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void printThreadInformation() { | |
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); | |
ThreadGroup parent; | |
while ((parent = threadGroup.getParent()) != null) { | |
threadGroup = parent; | |
Thread[] threads = new Thread[threadGroup.activeCount()]; | |
threadGroup.enumerate(threads); | |
for (Thread thread : threads) { | |
String identity = thread.getThreadGroup().getName() + "::" + thread.getName(); | |
System.out.println(identity + ", Priority: " + thread.getPriority() + ", Daemon: " + thread.isDaemon()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment