Use the Thread View as the primary view for
detecting thread bottlenecks. It displays a record of the activity of each
of the threads in your program, and helps you identify thread contentions
and deadlocks.
A contention occurs when a thread is waiting for a resource that
is not readily available; it slows the execution of your code, but can clear
up over time.
A deadlock occurs when a thread is waiting for a resource
that a second thread has locked, and the second thread is waiting for a resource
that the first thread has locked. More than two threads can be involved in
a deadlock. A deadlock never resolves itself. It often causes the whole application,
or the part that is experiencing the deadlock, to halt.
To locate thread
contentions and deadlocks:
- Display the Thread View: Right-click your
Thread Analysis profiling resource, and then click .
- In the Thread View, look for vertical arrows
between threads. A single arrow indicates a thread contention where
one thread is waiting for another thread to release a lock. Multiple arrows
indicate a deadlock when the two threads belong to the same Deadlock thread
state. A diamond-shaped marker indicates that although a thread is waiting
for a lock, the thread that holds the lock cannot be determined.
- Pause your cursor over a thread segment that is waiting for a lock
or deadlock. This displays a ToolTip that specifies the name of the lock and
identifies the thread that is holding the lock.
Here is an example of a contention:

Here is an example of a deadlock:

Note: If you profile a program with the
Execution Time Analysis profiling type, you can collect and display thread
data, but only for threads in the Running and Dead states. To display bottlenecks,
you must include the Thread Analysis profiling type in your profiling set.
The
following topics provide instructions for controlling the Thread
View: