Proof Garden
A small untidy garden is open
to computer scientists who can enter through either of two
turnstiles to the East and to the West of the garden.
- a student writes a Java program to count how many people are in
the garden at any one time.
- the program has two processes, each of which monitors a turnstile and increments a shared counter whenever someone enters via that processes' turnstile.
Garden.java
Magee&Kramer.java
The code is essentially the same as the Magee & Kramer version: the only
difference is the order in which the Java threads run. Both orders are
legal. However only the Magee & Kramer order (which is unlikely in practice)
leads to loss of increment.
Last modified: 18:06, 25-Apr-2003