I don't quite understand how to display the stack trace.
我不太明白如何显示堆栈跟踪。
package zh.codegym.task.task16.task1604;
/*
显示堆栈跟踪
*/
public class Solution {
public static void main(String[] args) throws InterruptedException {
Thread thread = new Thread(new SpecialThread());
thread.start();
System.out.println("*****************");
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
System.out.println(element);
}
}
public static class SpecialThread implements Runnable {
@Override
public void run() {
System.out.println(this);
}
}
}