Ornamental Garden Problem

A large ornamental garden is open to members of the public who can enter through either one of two turnstiles to the East and to the West of the garden. The management want to determine how many people are in the garden at any one time. They design a computer system to do this. In the program produced, each turnstile is represented by a thread and updates a shared Counter object.

Unable to load applet

View Source

Demo List

This version does not work correctly as can be observed, increments to the Counter are lost so that the total number of people in the garden is not the sum of the people who entered through the turnstiles. See corrected version