问题
If I have two threads running concurrently in my program and put a breakpoint on one of them, will the other thread stop also halt when this breakpoint is hit, or will it continue executing regardless?
(I am writing in Java and using NetBeans)
回答1:
Breakpoints have an option how they should behave: to suspend a single thread or all threads
回答2:
I believe that each thread will stop once it hits the breakpoint in the code, while other threads will continue to run. I remember this from my Tomcat days.
回答3:
By default only the thread that hits the breakpoint stops. However, you can modify the behavior by changing the breakpopint properties.
回答4:
It might be interesting to note that in Eclipse and NetBeans the default behavior is to suspend the current thread when the breakpoint is hit, while in IntelliJ it suspends all threads.
来源:https://stackoverflow.com/questions/8174408/does-a-breakpoint-halt-all-threads