Read/Write Lock (6.5.1)

The ReadWrite Lock pattern is not trivial. Design and code a test harness for the implementation of this pattern provided in the CD that comes with the textbook. Your test harness should create a dozen or two threads that at random intervals either read or write a complex object (such as the position of exercise 6.1, Single Threaded Execution). Try to instrument the entire code to verify that access to read or write is granted or denied when appropriate.

Read/Write Lock (6.5.2)

The textbook implementation of the ReadWrite Lock pattern is a specialized form of the Scheduler pattern. For some applications, e.g., the very "bid system" discussed in the textbook as a client of this pattern, an alternative and simpler implementation is viable. Under the assumption that there are not waiting writers all the time and the order of pending writes is irrelevant (as for a "bid system"), no queue is needed. Writers, similarly to readers, are simply held until access is non-deterministically granted.

Design, code and test this alternative implementation of the ReadWrite Lock pattern.