public
static void dumpStack()
Prints
a stack trace of the current thread to the standard error stream. As
you see the implementation of dumpStack(), it calls the printStackTrace() Of the Exception class.
public
static void dumpStack() {
new
Exception("Stack trace").printStackTrace();
}
Example
class ThreadStackTrace implements Runnable{ void print(){ show(); } void show(){ display(); } void display(){ Thread.currentThread().dumpStack(); } public void run(){ print(); } public static void main(String args[]){ ThreadStackTrace task1 = new ThreadStackTrace(); Thread t1 = new Thread(task1); t1.start(); } }
Output
java.lang.Exception: Stack trace at java.lang.Thread.dumpStack(Thread.java:1342) at ThreadStackTrace.display(ThreadStackTrace.java:22) at ThreadStackTrace.show(ThreadStackTrace.java:18) at ThreadStackTrace.print(ThreadStackTrace.java:14) at ThreadStackTrace.run(ThreadStackTrace.java:26) at java.lang.Thread.run(Thread.java:722)
You
can read the below posts for more information about Stack Trace
No comments:
Post a Comment