IntelliJ Thread Debug

28,212

Solution 1

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.

Solution 2

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

Solution 3

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.

Share:
28,212
Dane Balia
Author by

Dane Balia

Updated on July 09, 2022

Comments

  • Dane Balia
    Dane Balia almost 2 years

    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.

  • Dane Balia
    Dane Balia over 11 years
    Thanks - I did alter the "suspend policy" and even made the default to "Thread" - but still no suspension. I then spawned just'one' thread, (commented out the second) - and still there is no breakpoint. When I do a thread dump, I do see an error - but I have a breakpoint before that line. This is weird. You have any ideas?
  • RNJ
    RNJ over 11 years
    How are you building/running? At times when I deploy my code can be out of date to what is deployed. If that happens then my breakpoints go really funny...
  • Dane Balia
    Dane Balia over 11 years
    You right - it's working now. Did a proper build and all is well. Thanks guys. also made all breakpoints default to 'Thread'
  • Dane Balia
    Dane Balia over 11 years
    The real reason for the problem was that I had created a whole bunch of breakpoints prior to setting the suspend policy, and even though I set "default" to Thread, the old breakpoints were set to "All". I had to manually reset them to the default. That WORKED! So that was IT!
  • Lena Bru
    Lena Bru almost 10 years
    if you call run() the method runs synchronously, and when you call start the method run, runs asynchronously , when the method is run async the thread doesnt stop at the breakpoint for some reason