Java Data Type Tutorial - Java Thread.dumpStack()








Syntax

Thread.dumpStack() has the following syntax.

public static void dumpStack()

Example

In the following code shows how to use Thread.dumpStack() method.

//w  w  w  . j  a v a  2 s.  com
public class Main {

   public static void main(String[] args) {

     Thread t = Thread.currentThread();
     t.setName("java2s.com thread");
     
     System.out.println("Thread = " + t);
    
     int count = Thread.activeCount();
     System.out.println("currently active threads = " + count);
    
     Thread.dumpStack();
   }
}

The code above generates the following result.