Debugging Multithreaded Tomcat

Hi everybody,

I have a Java Spring Web App built in IntelliJ.
I can debug (remote and local) without any problems.
Now I would like to debug two concurrent request to test a piece of code which depends on proper SQL lock handling.

So the best way for me would be to have two debug sessions in my IntelliJ IDE and I can switch between those.
These two have to run in parallel.

My experience so far is that when debugging in IntelliJ there is only one thread running. So two requests are never handled in parallel.

Is there any solution to this problem?

Thanks in advance.

Pascal

2 comments
Comment actions Permalink

My experience has been that using a debugger with multi-threaded apps is
pretty much impossible because the debugger can only connect to one
thread at a time, while the others run freely.

Instead, I use detailed logging with thread labels to trace what
happens, when, and in what thread. No, it's not as convenient as being
in a debugger because it may take several runs before figuring out the
needed logging so that the whole picture is revealed, but it does work.

With modern logging frameworks, it doesn't even add any significant
overhead when turned off, and you might find yourself going back to a
particular piece of code repeatedly.

Donald

On 9/22/14 9:47 AM, Pascal Chorus wrote:

Hi everybody,

>

I have a Java Spring Web App built in IntelliJ.
I can debug (remote and local) without any problems.
Now I would like to debug two concurrent request to test a piece of code which depends on proper SQL lock handling.

>

So the best way for me would be to have two debug sessions in my IntelliJ IDE and I can switch between those.
These two have to run in parallel.

>

My experience so far is that when debugging in IntelliJ there is only one thread running. So two requests are never handled in parallel.

>

Is there any solution to this problem?


0
Comment actions Permalink

Hi,

if it is inside one VM, use breakpoint suspen policy = thread. This will stop a single thread and then others if breakpoint is hit there.
Then you can step in several threads switching them in threads combo box.

If it is inside different VMs, then really several debug sessions should work fine.

Hope it helps.

0

Please sign in to leave a comment.