Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static String dumpStack(Thread t) { StringBuilder sb = new StringBuilder(); sb.append(t.getName() + "[" + t.getId() + "] - " + t.getState() + ":\n"); for (StackTraceElement ste : t.getStackTrace()) { sb.append("\tat " + ste.getClassName() + "." + ste.getMethodName() + "(" + ste.getFileName() + ":" + ste.getLineNumber() + ")\n"); } return sb.toString(); } }