how to use dumpStack() in context of Threading.

General discussion on technical and managerial topics
no avatar
Ankit Jain
 
Posts: 1
Joined: Sat Jul 14, 2012 4:32 pm

how to use dumpStack() in context of Threading.

by Ankit Jain » Sat Jul 14, 2012 4:44 pm

Any one know how to use dumpStack() in context of Threading .


Please reply me soon..............

no avatar
Luis93
 
Posts: 6
Joined: Sat Jan 12, 2013 11:27 am

»

by Luis93 » Sat Jan 19, 2013 9:07 pm

Code: Select all
/*
 * Output:
 *
current thread: Thread[My Thread,1,main]
currently active threads: 1
0: Thread[My Thread,1,main]
java.lang.Exception: Stack trace
  at java.lang.Thread.dumpStack(Thread.java:1158)
  at MainClass.main(MainClass.java:23)

 *
 
 * 
 */

public class MainClass {
  public static void main(String args[]) {
    Thread t = Thread.currentThread();
    t.setName("My Thread");
    t.setPriority(1);
    System.out.println("current thread: " + t);
    int active = Thread.activeCount();
    System.out.println("currently active threads: " + active);
    Thread all[] = new Thread[active];
    Thread.enumerate(all);
    for (int i = 0; i < active; i++) {
      System.out.println(i + ": " + all[i]);
    }
    Thread.dumpStack();
  }
}






Vietnam tours Organised trips Vietnam Paloma junk

Return to General Discussion