Threads and Processes
Threads and processes are related concepts in computer science. Both represent sequences of instructions that must execute in a specific order. Instructions in separate threads or processes, however, can execute in parallel.
Processes exist within the operating system and correspond to what users see as programs or applications. A thread, on the other hand, exists within a process. For this reason, threads are sometimes called light-weight processes. Each process consists of one or more threads.
The existence of multiple processes enables a computer to perform more than one task at a time. The existence of multiple threads enables a process to break down work to be performed in parallel. On a machine with multiprocessors, processes or threads can run on different processes, enabling true parallel processing.
Perfect parallel processing is not always possible. Threads sometimes need to be synchronized. One thread may need to wait for a result from another thread, or one thread may need exclusive access to a resource that another thread is using. Synchronization problems are a common cause of bugs in multithreaded applications. Sometimes threads may end up waiting for a resource that never becomes available, resulting in a condition called deadlock.
The Visual Studio debugger provides powerful but easy-to-use tools for debugging threads and processes.
Tools for Debugging Threads and Processes in Visual Studio
The primary tools for working with threads and processes in Visual Studio are the Attach to Process dialog box, the Processes window, and the Threads window. The following table shows the type of information available in each place and the actions you can perform in each place:
|User Interface||Information Available||Actions You Can Perform|
Attach to Process dialog box
Available Processes you can attach to:
Select a process to attach to.
Select a remote machine.
Change transport type for connecting to remote machines
Threads in current process: