First submission deadline: 11 February
Final submission deadline: 25 February

Lab 2: Trainspotting (Part II)

In this assignment, you will implement a variation of the program to control the two trains that uses monitors rather than semaphores.

Choice of programming language

In this assignment you must use Java.


Your assignment is to adapt the program that controls the trains from the Lab 1 to use monitors instead of semaphores.


Getting started

Use the same project for the previous. Copy to, renaming the class, and change to use Lab2 instead of Lab1. You do not need to change the map file.

Tips and Tricks

To give you some hints, you should think that each track is represented by a monitor. The monitor will have, at least , the following interface:

public void enter()
public void leave()

where enter() is called by a train when entering a single track and leave() when a train leaves a single or double track.


In your submission, you should clearly explain the following items:

Concurrent Programming 2016 - Chalmers University of Technology & Gothenburg University