List of usage examples for java.lang StackTraceElement StackTraceElement
private StackTraceElement()
From source file:org.openflamingo.remote.thrift.thriftfs.ThriftHandlerBase.java
/** * Return a list of threads that currently exist with their stack traces *//*from www .j av a 2 s .co m*/ public List<ThreadStackTrace> getThreadDump(RequestContext ctx) { List<ThreadStackTrace> dump = new ArrayList<ThreadStackTrace>(); Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces(); for (Map.Entry<Thread, StackTraceElement[]> entry : traces.entrySet()) { final Thread t = entry.getKey(); final StackTraceElement[] frames = entry.getValue(); ThreadStackTrace tst = new ThreadStackTrace(); tst.threadName = t.getName(); tst.threadStringRepresentation = String.valueOf(t); tst.isDaemon = t.isDaemon(); tst.stackTrace = new ArrayList<StackTraceElement>(); for (StackTraceElement ste : frames) { StackTraceElement tFrame = new StackTraceElement(); tFrame.className = ste.getClassName(); tFrame.fileName = ste.getFileName(); tFrame.lineNumber = ste.getLineNumber(); tFrame.methodName = ste.getMethodName(); tFrame.isNativeMethod = ste.isNativeMethod(); tFrame.stringRepresentation = String.valueOf(ste); tst.stackTrace.add(tFrame); } dump.add(tst); } return dump; }