On an exam in my operating systems class, the last problem involved several processes representing visitors at Jurassic Park, and getting them to share the resources available. The second part involved adding a Tyrannosaurus to the mix, who ate the occasional tourist. Afterwards, I decided to actually implement this in Java, because it would be fairly easy. This is the result.
The ten visitors start out in the musuem, the tiled area at the upper left. They wander about for a bit, then decide to go for a ride. There's five jeeps parked on the pavement in the lower left. If there's one available, they get in, then wait for no one to be using the only gate. They head out, drive around for a while, getting to see the T Rex safely in its paddock. When they get bored, they head back, wait for the gate, park the jeep, and go back to the museum. In the second version, the T Rex is loose, and wandering about the park. It occasionally gets hungry and eats someone out of one of the Jeeps without returning it to the parking lot. Eventually, everyone will pile up waiting for Jeeps to come back, and the T Rex will sit around waiting for the next meal that will never come, illustrating deadlock.
© Andrés Santiago Pérez-Bergquist, All rights reserved. The reproduction of this work, by any means electronic, physical, or otherwise, in whole or in part, except for the purposes of review or criticism, without the express written consent of the author, is strictly prohibited. All references to copyrighted and/or trademarked names and ideas held by other individuals and/or corporations should not be considered a challenge to said copyrights and trademarks.
If you wish to contact the author, you may do so at