How to: Use the Threads Window
This topic applies to:
Visual Studio Edition |
Visual Basic |
C# |
C++ |
J# |
Web Dev |
Express Edition |
No |
No |
No |
No |
No |
Standard Edition |
Yes |
Yes |
Yes |
Yes |
|
Pro/Team Edition |
Yes |
Yes |
Yes |
Yes |
With the Threads window, you can examine and control threads in the program you are debugging. A thread is a sequence of executable instructions created by a program. By default, a program has a single thread. Multithreaded programs create additional threads. On a single CPU, one thread is active at a time. The active thread is the thread that is currently able to run.
From the Threads window, you can set the active thread. In addition, you can freeze or thaw the execution of each individual thread. Freezing prevents the execution of a thread. Thawing enables it to continue. Two vertical blue bars identify a frozen thread.
To display the Threads window in break mode or run mode
- From the Debug menu, point to Windows, and then click Threads.
To set an active thread
In the Threads window, right-click a thread, and click Switch to Thread on the shortcut menu.
-or-
Double-click the thread to make it active.
A yellow arrow identifies the active thread.
To freeze — prevent execution of — a thread
- In the Threads window, right-click a thread, and click Freeze on the shortcut menu.
To thaw — allow execution of — a thread
In the Threads window, right-click a thread, and click Thaw on the shortcut menu.
The absence of vertical blue bars identifies a thawed or unfrozen thread.
You can suspend or resume thread execution using calls to
SuspendThread
andResumeThread
. In MFC, you can useCWinThread::SuspendThread
andCWinThread::ResumeThread
.These calls change the Suspend count shown in the Threads window. To execute, a thread must be unfrozen and have a Suspend count of zero. You cannot change the Suspend count or resume a suspended thread from the Threads window.