Figure 3-3.

A diagram showing happens-before relationships of the example code.

Operations on two threads are shown.

The first thread starts with an operation that repeats several times: acquire-load false from ready. It is followed by acquire-load true from ready, and finishes with load 123 from data. Each box in this sequence has an arrow pointing to the next one.

The second thread is represented by just two operations. First, store 123 to data. Then, release-store true to ready. An arrow connects these two boxes in order.

There is one arrow between the threads. It goes from the release-store of true on the second thread to the acquire-load of true on the first thread.

This last arrow forms the last part of the three-arrow path connecting the store 123 to data on the second thread and the load 123 from data on the first thread.

  1. The arrow within the second thread from “store 123 to data” to “release-store true to ready”.
  2. The arrow to “acquire-load true from ready” that connects the threads.
  3. The final arrow within the first thread to “load 123 from data”.