Java Thread.getAllStackTraces()

Syntax

Thread.getAllStackTraces() has the following syntax.

public static Map < Thread , StackTraceElement []> getAllStackTraces()

Example

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


/*from   ww  w  .  j  a v  a 2  s . co  m*/

import java.util.*;

class ThreadDemo implements Runnable {
  
   public void run() {
    
      System.out.println("This is run() method");
   }
}

public class Main{

  
   public static void main(String args[]) {
      
     ThreadDemo trace = new ThreadDemo();
     Thread t = new Thread(trace);
    
     // this will call run() method
     t.start();
    
     // returns a map of stack traces
     Map m = Thread.getAllStackTraces();
   }

}




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable