• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get Thread dumps

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

What are thread dumps? how to obtain it?

Regards,
Ajay.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A thread dump is a snapshot of calls made in the current thread. It can be used for backtracing or debug a method call.

Thread.dumpStack() prints the stack trace of the current thread.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ajay Xavier:
hi,

What are thread dumps? how to obtain it?

Regards,
Ajay.



A "thread dump" is basically a stack trace of every thread in the JVM, at the time of the dump. It is generally useful, if you have exhausted every other option. It generates too much data for my liking.

Anyway, with Unix/Linux, you can obtain the dump by sending a signal 3 to the PID of the JVM. With Windows, I believe this can be obtained via a CNTRL-BREAK, in the command windows of the JVM.

Henry
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Originally posted by Henry Wong:

With Windows, I believe this can be obtained via a CNTRL-BREAK, in the command windows of the JVM.



Hi Henry, Could you please explain your above statement.

I mean how do I obtain stack trace of all threads on windows plateform. What CNTRL-BREAK mean?

Thanks in advance

Regards

Naseem
[ June 30, 2006: Message edited by: Naseem Khan ]
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I mean how do I obtain stack trace of all threads on windows plateform. What CNTRL-BREAK mean?



Move/Click mouse focus to the command window that is running the JVM -- assuming that you started it from the command prompt.

While holding the control key, press the break key.

Henry
 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anyway, with Unix/Linux, you can obtain the dump by sending a signal 3 to the PID of the JVM



can you please explain how to send a signal 3 to the PID of the JVM?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ajay Xavier:


can you please explain how to send a signal 3 to the PID of the JVM?



Use the "ps" command to list the processes running. Go through the list to find the JVM that you want the thread dump of -- and take note of the process ID.

To send a signal 3, you need to use the kill command:

$ kill -3 <PID>

where <PID> is replaced with the actual process ID number that you obtained from the "ps" command.

BTW, it has been awhile since I did this... but I am 99.44% sure it's a signal 3...

Henry
[ June 30, 2006: Message edited by: Henry Wong ]
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Henry. With your help, I am able to see the stackTrace of all threads.

Here is the stack trace which I got from command prompt on windows 2k plateform.



Actually I was not able to search break key on my keyboard. I pulled out my keyboard and finally on encyclopedia I got pause and break same key.


Naseem
 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

$ kill -3 <PID>



The process gets killed but the thread dump is not getting printed. will it get printed in the console or written to some log file.

Regards,
Ajay.
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A brief Google tells me that Henry was correct. The thread dump should be in dump-out.log. Where that log file is created I don't know, but based upon experience I would say it's probably in the folder the process was started from.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apparently it's platform dependent. When I send signal 3 to one of my XMLRPC servers on one of our Linux boxes I get the dump scrolled in the terminal window. I'll paste it so you have some idea of what it might look like:

 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ajay Xavier:


The process gets killed but the thread dump is not getting printed. will it get printed in the console or written to some log file.

Regards,
Ajay.



The process should actually *not* terminate. A signal 3 should only cause a thread dump. The JVM should continue running.

Don't know about all cases, but when I did this for Solaris and Redhat, it just went to wherever the JVM was sending output to.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic