Concurrent Programming with Java
Lab Manual, Version 1.0, F. Astha Ekadiyanto, 2002.

[Contents] [Next] [Previous]


Lab 4: Introduction to Threads

Here is a simple introduction of a Timer Thread Object based on the previous Case Problem.
Try to Click and Drag your mouse over the shapes as many times as you wish. You will notice that each time your releases your mouse, a MobileStation (represented as a point) will move according to the Path you have just created. You could just create as many MobileStations as possible and each of them will run concurrently.

It is does not work (probably versioning problem), then download the JAR File and execute from command line ( java -jar lab4.jar )

ALT="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is ignoring the <APPLET> tag!

Why threads ?

Users hate unresponsive software. When users click a mouse, they expect a program to instantly respond to their requests, even when the program is in the midst of a time-consuming activity, such as repaginating a long document or waiting for a network operation to complete. Programs that respond slowly to their users exhibit poor performance. To improve a program's performance, developers typically use threads. [Jeff Freisen, Achieve strong performance with threads]

In this Lab., you will learn:

Preparation for the Lab.:

To prepare for the lab, please extract the last Lab's solution (lab3.zip) into a new directory lab4 (or any name you'd like). We will use all the classes we have defined in the previous labs to work on this Lab. Make sure you can load the Project into BlueJ. This should have a display like the followings (and probably will not changed by the end of this Lab).


[Contents] [Next] [Previous]