Poison

Debug Multithreaded Applications

在调试多线程应用程序时,有时我们需要暂停单独的线程而不是整个应用程序,此时在断点上可以设置 SuspendThread,而不是默认的 All。关于这两个选项的区别,在 Breakpoints | IntelliJ IDEA 中的说明如下:

The following policies are available for the breakpoints that suspend program execution:

  • All: all threads are suspended when any of the threads hits the breakpoint.
  • Thread: only the thread which hits the breakpoint is suspended.
References

Tutorial: Detect concurrency issues | IntelliJ IDEA