Adding threads and thread pools

You can add threads or thread pools to the Performance Measurement tool to ensure that generated reports include the data that you require for analysis. If you add a thread or complete parts of an operation on a thread pool, propagate the ID of the parent operation to produce valid caller and stack reports.

Use the following sample code to help you create your custom code to propagate the parent operation ID when you start a new thread:
* Sample to show how to propagate the parent operation identifier when
* starting a new thread.
* 
* @throws InterruptedException
*             unexpected
*/
public void startThreadSample() throws InterruptedException {
  
  // propagate the call hierarchy across threads or thread pool
  final Long parentID = OperationMetric
  .getThreadParentOperationIdentifier();
  
  Thread myThread = new Thread(new Runnable() {
    @Override
    public void run() {
      OperationMetric.setThreadParentOperationIdentifier(parentID);
      // perform work
    }
  });
  
  myThread.start();
  myThread.join();
}