Debugging Threads in the IDE

See Also

All the threads created in the current session are displayed in the Threads window. You can open the Threads window by choosing Window > Debugging > Threads (Alt-Shift-7).

Changing the Current Thread

Only one thread is the current thread at any given time. By default, the current thread is the thread within the current session from which the debugger gained control. When you switch between threads to debug, the Call Stack and Local Variables windows are automatically updated to reflect the data applicable to that thread.

To change the current thread:

Suspending and Resuming Threads

You can suspend execution of a thread if you think it is causing problems and then later resume the thread once the problem is solved.

In the Threads window, the icon to the left of the thread name indicates whether the thread is suspended or waiting to be resumed.

Icon Description
Current thread Indicates the current thread
Running thread Indicates a thread that is running and is not current
Suspended thread Indicates a thread that is suspended and is not current

You can display the Suspend property as a boolean flag (True or False) in the Threads window by clicking the columns button (Change Column) and select the Suspend checkbox.

To suspend or resume a thread:

Multi-threaded Applications

When debugging a multi-threaded application, a step in a particular thread may be interrupted by a breakpoint encountered in some other thread. This behavior is desirable in some cases but not in others.

Let us suppose you are stepping through a thread (thread 1), and one of the steps is interrupted by a breakpoint encountered in another thread (thread 2). When this happens, the program counter is set to the breakpoint in thread 2.

You can continue stepping through your program in the following ways:

Viewing Source Code for a Thread

You can view the source code of a thread in the IDE's Source Editor if you think it is causing problems and want to examine it further.

To view a thread's source:

See Also
Creating a Watch
Using the Call Stack
Stepping Through Your Program

Legal Notices