|
|
|
Expiriment in Multi-Threading
This applet attempts to show Java's multi-threading capabilites.
The applet itself implements the Runnable interface, then loads three
instances of a clock class, which extends the Thread class.
- The Clock in the upper left is implemented in the applet's main
class. The thread runs once per second and the thread's priority is set
maximum, so it takes priority over all other threads.
- The clock in the upper right is an instance of the Clock class.
This thread runs one every three seconds.
- The clock in the lower left is another instance of the clock class.
This thread runs every five seconds.
- The clock in the lower right is another instance of the clock class.
This thread runs once every two seconds.
- The applet uses a GridLayout and initializes four separate canvases.
- Each instance of the clock class receives a canvas as its drawing surface.
You can view a copy of the source code
Here
savidge@scsud.ctstateu.edu
|