# Exercise 3: Examining Threads

In this exercise, you will view the thread groups, threads, and stack frames that make up the Blink project. You will also learn how to track the changes in variable values as the program progresses.

1. Choose Debug -> Threads/Stack.
   The Java WorkShop Threads/Stack window is displayed.

   The Blink project includes three thread groups, each of which is accompanied by the glyph:

   - `main`--includes threads that run in Java WorkShop
   - `sun.applet.AppletViewer.main`--includes threads that run in the applet viewer
   - `file:/your-installation-directory/jws/Blink/-threadGroup`--contains threads directly related to the Blink project
   The `sun.applet.AppletViewer.main` threads group contains three threads; and the `Blink` file thread group contains two threads.
2. Look at `"AWT-EventQueue-0"`, the first thread in the `sun.applet.AppletViewer.main` thread group.

   You'll see the following:

   - The thread name is `java.awt.EventDispatch`
   - The thread state is "at breakpoint".
   - The priority for running the thread is priority 5. The thread with the highest priority is run first.

   The glyph accompanying a thread is an additional clue as to the state of the thread. Possible glyphs you might come across include:
   The thread is suspended.
   The thread is stopped at a breakpoint.
   The state of the thread cannot be determined.
   The thread is a zombie.
   The thread is running.
   The thread is sleeping.
   The thread is waiting on a conditional variable.

3. Look at the call stack that makes up the thread class.
   The call stack includes all the methods that have been called but have not returned.`Blink.paint`, which was executing when the program stopped, is at the top of the stack. The stack frame is highlighted so you can easily tell where the program stopped. Each stack frame is accompanied by the glyph.
4. Open the `Blink.paint` stack frame by clicking the + next to the glyph.
   Java WorkShop shows the variables and their current values local to `Blink.paint`. Look at the variable `word`. Look at the value of the `word` variable.
5. Click the Go button on the Edit/Debug toolbar.
   The program runs through the loop and stops when it hits the breakpoint a second time. The Threads/Stack display is updated, the value of the `word` variable changes. The value cycles through "Java WorkShop is really cool :-)".
6. Open the `this` object by clicking the + next to the glyph.
   Java WorkShop expands the object to show all contained variables within the object. You can repeat this action on nested objects (for example, `peer`).
7. Click the - to the left of the `this` object.
   Java WorkShop contracts the object.

Next lesson:

  Exercise 4: Stepping Through a Method