CISC 370 Lecture Notes for Class No. 26 May 11, 2000
Java Threads Continued

Course Home Prev Lect Next Lect Example Progs Exercise Solns
CoreJava Progs
Documentation
Gen'l Docs Java 2 APIs Java Glossary Term Proj Info

Assignment

Reading:
Horstmann & Cornell, Vol II, chapter 1 on Multithreading or the online chapter on threads from the Java Tutorial by Campione and Walrath.

Today's Lecture Topics

  1. Threads are often used for animation. In the last lecture, we used threads to animate a traffic light and to flash the sign in a predestrian light. These were examples of "discrete" animation as opposed to smooth continuous motion. In this example, we use threads to animate smooth continuous motion of a thermometer as the temperature drops rapidly. There are three main classes for this example:

    (1) Thermometer that defines a thermometer object. This class extends the Observable class.
    (2) ThermoCanvas that implements the interface Observer and handles the display of thermometers. And
    (3) ThermApplet that creates an applet with two thermometer displays of a single thermometer object T. It also creates a thread whose run method animates the thermometer.

    There are a number of things to keep straight in this example that can be confusing. These include:

    • There are two start methods that should not be confused. One is the start method for the applet. It is implemented in the class ThermApplet. The other is the start method from the Thread class that is invoked to start the animatorThread in the ThermApplet class.

    • Also note the diagnostic output that tells you when various methods get called. Try iconizing the applet while it is running and notice that its stop() method is called. When the applet window is re-displayed the applet's start() method is invoked again. On this invocation the thread's resume() method is called.

    • Finally, note the object-oriented nature of the code. The class Thermometer implements a simple thermometer object. The class ThermoCanvas implements a canvas for displaying a thermometer object. Neither has nothing to do with applets, threads, or animation. The creation of the thread and the animation is done entirely in the ThermApplet class.

  2. Course Evaluations

    Please add comments to the back of the evaluation forms. In particular, please address the following questions. Be as explicit as possible in your responses.

    1. What material or aspects of the course were most difficult for you? What was easiest and why?

    2. Did the overall structure of the course minimize/maximize your learning? Would it have been more instructive to have had
      (a) one or more tests? For example, a test around mid-term when we finished the basics of the Java language?
      (b) Once you started working on your term projects I suspended exercise assignments. Would it have been helpful to you to have continued to give some of these exercises? Explain.

    3. Was the pace that the material was covered too fast/too slow/about right. Did you do most/little of the assigned reading?

    4. Were the online materials (course web pages, links to SUN and other web pages) effective instructional tools? Why? Were the inclass handouts needed? Why?

    5. What did you like most/least about the course?

    6. Have you learned more/about the same/less than you would if the course were structured more traditionally with tests, multiple smaller programming projects, and a final exam?

    7. Would you be interested in a follow-on course on web and e-commerce technologies that covers such Java topics as the database facility JDBC, Java beans for component programming, servlets for server-side applications plus other topics?

    8. Addiitonal specific suggestions for improvement would be appreciated.

Back to the CISC 370 homepage.

Corrections, suggestions and comments to Bob Caviness

Copyright 2000 B. F. Caviness This page has been accessed times since 11 May 2000.