This is Exercise 5.14 in the text. Remember that Java monitors are `signal and continue' so be sure to think about the ramifications of this as you design your monitor.
No semaphores and no busy waiting allowed!
Do not use nap()
within a monitor synchronized method.
Do you see why?
Only three nap()'s are allowed in this program:
riders wandering
cars bumping
and one in main() to shutdown
the simulation.
If you have not already done so animate your program using XtangoAnimator.java.
Permission is granted to copy and distribute this material for educational purposes only, provided that the following credit line is included: "Concurrent Programming using Java, Copyright 1997 Stephen J. Hartley." Permission is granted to alter and distribute this material provided that the following credit line is included: "Adapted from Concurrent Programming using Java, Copyright 1997 Stephen J. Hartley.