views:

89

answers:

2

I have a web application running in a jboss application server (But it is not jboss specific so we could also assume it is a tomcat or any other server). Now I have the problem that one thread seems to be in dead-lock situation. It uses 100% CPU all the time. I have started the server with enabled debug port and I can connect Eclipse to it. But the problem is: There are a lot of threads running. How can I find the right thread? I know the process id (from Linux "top" command) but I think this will not help. Do I really have to open each thread separately and check what they are currently doing? Or is there a way to filter the threads for "most active" or something like that in Eclipse?

+2  A: 

You can try and generate a thread dump (CTRL+Break as shown in this thread).

Or you could attach a JConsole to the remote session (so leaving Eclipse aside for now), monitor the threads and generate a thread dump.

alt text

VonC
A simple thread dump is indeed all I needed. To find the thread which uses so much CPU I can use the program "htop" on Linux which can also display and CPU-usage-sort threads (and not only processes like "top"). So htop gives me a thread ID and this thread id can also be found in the thread dump which gives me the stack trace of the problematic code. perfect.
kayahr
+1  A: 

Seems to be you need to narrow things down to the code that has the bug by identifying which thread is eating the CPU first, then which code is being executed by that thread and at that point you can remote debug.

I would suggest using something like JProfiler, jvisualvm, jconsole or something similar. Using one of these tools will allow you to get some insight into what the thread is doing and should allow you to sort the threads by cpu cycles used so you kind find the offending thread quickly.

Malcolm Featonby