Skip to content

Instantly share code, notes, and snippets.

@rajivrnair
Created March 30, 2015 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajivrnair/48a742ce632caab3f9a5 to your computer and use it in GitHub Desktop.
Save rajivrnair/48a742ce632caab3f9a5 to your computer and use it in GitHub Desktop.
Print information about currently running threads
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