Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Thread Debug

Does IntelliJ IDEA provide thread-debugging? That is - Netbeans allows you to debug multiple threads, and halting at those breakpoints (automatically). However all I seem to be getting in IntelliJ is "thread dumping", which seems to be an analysis that is manual, and a snapshot taken when I clicked 'Thread Dump'.

Is there something I'm missing? I have google'd and not found sufficient information to assist.

like image 291
Dane Balia Avatar asked Sep 25 '12 10:09

Dane Balia


3 Answers

I think you can. I have suspended threads via breakpoints by setting the suspend policy. This will suspend the thread that is executing this piece of code. If you have multiple thread then I would think they would carry on.

To quote the suspend policy

  • Item Description
  • All : When the breakpoint is hit, all threads are suspended
  • Thread : When the breakpoint is hit, the thread where the breakpoint is hit is suspended.
  • None: No thread is suspended.
like image 140
RNJ Avatar answered Oct 05 '22 17:10

RNJ


You have a nice Threads view available.

Press the little gearwheel and you will see all active threads.

enter image description here

And on each breakpoint you can set the Suspend Policy. You can either make the Thread alternative the default for all breakpoints or you can set them individually on each breakpoint.

enter image description here

like image 40
maba Avatar answered Oct 05 '22 18:10

maba


For me the problem with not accessing thread still occcurs. I set up brakepoints to all. And put brakepoints inside calling methods. What I noticed is that the method in new thread is beeing accessed when i call run() but not start(). Just wondering why, AFAIK the start() method should call run(). Nevertheless, the output from thread occurs even I call .start(), but never access it.

like image 25
Jacob Avatar answered Oct 05 '22 17:10

Jacob