Lab 5: Concurrency

The goal of this lab is to practice using concurrency.

1. Introduction and set up

You will be working with a train simulation. There are two trains running on elliptical tracks that meet at four points. In the code as you get it, they will (almost certainly) crash at the crossings. You need to modify the code so that they do not crash.

Make a new directory for this lab and copy the files that I am giving you.

cp -r ~tvandrun/Public/cs245/lab5/trains .

Then start Eclipse and make a new Java project in the directory you made.

2. Your task

Try running the program as it is and confirm that the trains crash.

Then fix it. All the coding you need to do is in Train.java. All you need to know about the rest of the code you can learn by looking at the interfaces Track.java and TrackPosition.java. The only new thing you need to know about Java is how locks, monitors, and synchronized stuff works.


Thomas VanDrunen
Last modified: Thu Sep 22 12:38:43 CDT 2011