静态dumpstack()方法提供一个new exception ("stack trace").printstacktrace ()的封装,打印一个追踪当前线程的堆栈
public class TestDumpStack
{
public static void main(String[]args)
{
new Common().getInfo();
}
}
class Common
{
private String info = "dump stack";
public String getInfo()
{
Thread.dumpStack();
return info;
}
}
运行结果会显示:
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Unknown Source)
at Common.getInfo(TestDumpStack.java:16)
at TestDumpStack.main(TestDumpStack.java:6)
为什么会是Unkown Source
分类:
java lauguage
本文转自wanqi博客园博客,原文链接:http://www.cnblogs.com/wanqieddy/archive/2012/05/05/2484965.html
如需转载请自行联系原作者