Exercise 1.2: Collecting thread data

Before you begin, you must complete Exercise 1.1: Importing the required resource.

Scenario: The program that you will be investigating runs briefly, and then abruptly comes to a halt. This happens every time you run the program. This behavior is typical of thread deadlocks, so you are asked to investigate how the threads in this program interact.

To locate possible thread deadlocks, you will first collect thread data and then analyze the data using the Thread View in the Profiling and Logging perspective.

Collecting thread data will allow you either to identify the deadlock or to rule out threads as the cause for the application's failure.

Preparing to collect thread data

To collect thread data, you must be in the Profiling and Logging perspective. To switch to this perspective:

  1. From the Software Development Platform menu bar, select Window > Open Perspective > Other. The Select Perspective dialog box opens.
  2. In the lower left of the dialog box, click Show all. A check appears in the check box.
  3. From the list of perspectives, select Profiling and Logging and click OK.
  4. If the Confirm Enablement dialog box opens, click Always enable capabilities and don't ask me again, and then click OK.
  5. The Software Development Platform switches to the Profiling and Logging perspective.

Collecting thread data for the philosopher application

To collect data:

  1. From the Software Development Platform menu bar, click Window > Show View > Console to open the Console view. The Console view allows you to follow the application as it processes.
  2. Create a profiling configuration:
    1. From the menu bar, click Run > Profile. The Profile dialog box opens.
    2. In the Configurations list, double-click the Java Application entry. A New_configuration entry appears.
    3. In the Name field, type PhilosopherThreads.
    4. In the Main tab, if philosopher is not already entered in the Project field, do the following:
      1. Next to the Project field, click Browse. The Project Selection dialog box opens.
      2. Select philosopher and then click OK.
    5. Next to the Main class field, click Search.
    6. In the Choose Main Type dialog box, click MaitreDHote, and then click OK.
    7. Click the Profiling tab.
    8. In the Overview sub-tab, select the Thread Analysis profiling set. (A profiling set defines the type of profiling data that is to be collected for the run.)
  3. Click Profile. The application runs, and the display changes as follows:

    Console view with program output

When the application reaches a certain point, it stops processing.  For this run, however, you have collected thread data, and you can now analyze why it has stopped.

If you were unable to collect data

Before you can collect any kind of profiling data, Agent Controller must be running. If you get a message that Agent Controller is not available, make sure that Agent Controller has been installed, start it manually, and try again. For instructions, refer to the installation guide. You can access the installation guide by using the launchpad, or you can find it on the product CD under disk1/install.html.

After you collect data, you are ready to begin Exercise 1.3: Identifying a thread bottleneck.

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.