Lesson 9:
Threads - A thread is an
independent sequence of actions in a program. A java program can have
several threads executing at the same time.
- The execution of a thread is started with the start()
method.
- All threads should include calls to the sleep(long
ms) or yield() which allows the thread to yield control to another thread.
Try this:
- Take a look at the file Bounce1.java from the web page.
Before you try it out BEWARE -- it is going to misbehave
and you may need to go into the Task Manager to manually kill it. Why
does this happen?
- Take a look at the file Bounce2.java from the
web page. Try it out.
- Change the code so that the start/stop button controls
three balls, of different colors, rather than just one ball.
- Add a button to add additional balls (up to 100,
total). Each press of this button adds one ball. All balls
should be stopped and removed when the stop button is pressed. The
start button continues to start a single bouncing ball.