Threads Lab I

CS 245

Oct. 6, 2004

  1. Download Bounce1.java from the class Web page. Compile and run it. Notice that you can start the bouncing ball, but you can't stop the bouncing ball.

    Looking through the code, explain exactly why the applet doesn't respond to click on the stop button.

    Notice how long it takes for the applet viewer to go away when you terminate it.

  2. Download Bounce2.java from the class Web page. Compile and run it.

  3. What happens if you comment-out the last call to draw() in Ball's run() method? (You may need to go through several start/stop cycles before you notice any changes.)

  4. Study actionPerformed() to learn how the animated ball is started and stopped.

  5. Extend the applet so that it starts and stops three animated balls, each a different color.

  6. Extend the applet by:
    1. Add a New Ball button. During ball animation, each time this button is pressed another ball is added to the mix of bouncing balls, up to a maximum of 20 balls.

    2. The stop button should stop all the bouncing balls.

    3. The start button should start a single bouncing ball.



Thomas P. Kelliher
Tue Oct 5 13:47:27 EDT 2004
Tom Kelliher