Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Monitoring and Controlling Execution of Threads

The IDE's Threads window (Alt-Shift-7), shown in Figure 5-8, enables you to view the status of threads in the currently debugged program. It also enables you to change the thread that is being monitored in other debugger windows (such as Call Stack and Local Variables) and to suspend individual threads. See Table 5-7 for a guide to the icons used in the Threads window.


Figure 5-8 Threads window

Table 5-7. Key to Icons in the Threads Window


Currently monitored thread


Currently monitored thread group


Running thread


Suspended thread


Thread group

Changing the current thread does not affect the way the program executes.

Switching the Currently Monitored Thread

The contents of the Call Stack and Local Variables windows are dependent on the thread being currently monitored in the debugger (otherwise known as the current thread). To switch the currently monitored thread:

  1. Open the Threads window by pressing Alt-Shift-7.
  2. Right-click the thread that you want to monitor and choose Make Current.

Suspending a Single Thread

By default, when your program hits a breakpoint, all threads are suspended. However, you can also configure a breakpoint so that only its thread is suspended when the breakpoint is hit:

  1. Open the Breakpoints window by pressing Alt-Shift-5.
  2. In the Breakpoints window, right-click the breakpoint and choose Customize.
  3. In the Customize Breakpoint dialog box, select Current from the Suspend combo box.

Isolating Debugging to a Single Thread

By default, all threads in the application are executed in the debugger. If you would like to isolate the debugging so that only one thread is run in the debugger:

  1. Make sure that the thread that you want debugged is designated as the current thread in the Threads window (Alt-Shift-7). The current thread is marked with the threadwindow.gif icon.
  2. Open the Sessions window by pressing Alt-Shift-6.
  3. In the Sessions window, right-click the session's node and choose Scope | Debug Current Thread.
  • + Share This
  • 🔖 Save To Your Account