The software described in this documentation is either in Extended Support or Sustaining Support. See for more information.
Oracle recommends that you upgrade the software described by this documentation as soon as possible.

5.8 Using the Thread Analyzer

The Oracle Solaris Studio Thread Analyzer is an advanced tool for application optimization that is designed to help you detect and analyze race conditions and deadlocks in multithreaded applications.

Data races can cause incorrect or unpredictable results, and they can occur arbitrarily far way from where a problem appears to occur. Data races occur under the following conditions:

  • Two or more threads in a single process concurrently access the same memory location.

  • At least one of the threads is accessing the memory location for writing.

  • The threads are not using any exclusive locks to control their accesses to that memory.

Deadlock conditions occur when one thread is blocked waiting on a resource held by a second thread, while the second thread is blocked waiting on a resource held by the first (or an equivalent situation where more than two threads are involved).

To instrument the source code for the detection of data race and deadlock issues, first compile the code with the -xinstrument=datarace flag, It is recommended that you also set the -g flag and that you specify no optimization level to help ensure that information about line numbers and call stacks is returned correctly.

You then execute the resulting application code using the collect -r race or collect -r deadlock command, which collect runtime information for the detection of data races or deadlocks during the execution of the process.

$ collect -r race app params
$ collect -r deadlock app params 

Finally, load the results of the experiment into the Thread Analyzer to identify any data race or deadlock conditions.