public static void dumpStackTraces(PrintStream out) { synchronized (out) { Map<Thread, StackTraceElement[]> sts = Thread.getAllStackTraces(); for (Thread t : sts.keySet()) { StackTraceElement[] st = sts.get(t); out.println(t.getName() + "[" + t.getId() + "]" + "(" + t.getState() + (t.isDaemon() ? ")(DAEMON):" : "):")); for (int i = 0; i < st.length; ++i) { out.println("\t" + st[i]); } } } }
Popular Posts
Blog Archive
- January 2015 (1)
- January 2013 (1)
- November 2012 (1)
- June 2012 (1)
- April 2009 (1)
- September 2008 (1)
2009-04-28
Dump java stack traces
This is a small utility function to programmatically dump all stack traces of a java process similar to the output of kill -QUIT on unix platforms. Use at your own peril, no warranties, no royalties :)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment