Work with Threads

Examine Data Tutorial Contents Home Page

Although the QuickMenu applet does not explicitly create threads in the user code, when the applet runs, several threads are spawned by system classes.

  1. Examine the Thread bar above the Source panel:

    <PIC>

    The first six threads (main, AWT-EventQueue-0, AWT-Input, AWT-Motif, thread applet-QuickMenu.class, and Screen Updater) are spawned by the appletviewer code.

    The current thread is highlighted with a colored border. You can control which thread is the current thread. When you make a thread current, you are focusing the debugging tools on that thread. Each thread's status can be determined by the icon to the left of its name:

  2. Make AWT-EventQueue-0 the current thread by clicking on it.

  3. Click the Suspend button.

    Notice that thread status information appears on the right side of the status line:

    Thread AWT-EventQueue-0: suspended 
    java.lang.Object.wait (Object:315)
    

    If you have installed the Java source files distributed with Cosmo Code, you see the source code for Object.java displayed in the Source panel with the current location highlighted. If you have not installed the source code, a message is displayed saying that the file cannot be found.

    When you suspend a thread, all debugging operations are relative to the thread.

  4. Hold down the right mouse button over the Terminate button and choose All Threads.

    This terminates all threads in the QuickMenu applet, effectively killing the applet. The Applet Viewer closes.

Congratulations, you have successfully debugged an applet in Cosmo Code. This step completes the tutorial.

Examine Data Tutorial Contents Home Page

Guide to the Cosmo Code Development Environment
12-96*163