Room. Look for the spots in the code where you must provide the implementation. Note: Think hard about what object the
LockPubinstances (4 of them per room) are trying to guard. It's not the north, south, east, west objects! Once this class emits its PCS signals, the test code in Startup will report it as such.
LockPub. The only method you have to implement is
lockInvoke. That method must go through the process of requesting the lock (on
o, not on itself), acquiring the lock, running the
Runnable, and releasing the lock. See the JavaDoc for the signals that need to be emitted along the way. Once it emits its PCS signals, the testing code will show when locks are requested, granted, and become available again.
DoubleLock. Here again, the only method you implement is
lockInvoke. Get a lock on
o1, using its
lockInvokemethod, which should get a lock on
o2similarly, and then with both locks in hand, run the
RunnableTesting code should now work on double locks. Note that the locks of a double lock are obtained in a random order; you should see this in your output.