Figure 9-2.
A diagram showing happens-before relationships in a situation with two threads.
Each thread is represented by a sequence of boxes, one per operation. Within each thread, each box has an arrow to the next.
The first thread starts with “lock” and “check data”, followed by a group of operations labeled “wait”. This group consists of four operations:
There is a large space bewteen the wait and lock operations, indicating the passing of time.
There is an arrow from the unlock operation to the first operation on the second thread, labeled “lock”. The second thread follows with “modify data” and “unlock”, from which there is an arrow back to the final “lock” operation on the first thread. The second thread follows with a group labeled “notify one” of two operations: “increment counter from 0 to 1” and “wake one”.
The first thread follows its final lock operation with “chekc data” and “unlock”.
There are no arrows between the wita and wake one boxes. The only inter-thread arrows are between lock and unlock boxes.