Figure 3-4.

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

Operations of two threads are shown, but dotted lines suggest there are more outside the frame of this diagram.

Each thread has three operations:

  1. Change locked from false to true (acquire)
  2. Accesss data
  3. Change locked from true to false (release)

Within each thread, there is an arrow between each of these operations in order.

There is also an arrow connecting the last operation of the first thread to the first operation of the second thread. In those two operations, the word “false” is emphasized, to show that this last arrow was formed because the acquire operation loaded the “false” that the release operation stored.

A gray dotted arrow comes in from outside of the frame of the diagram to the first operation of the first thread, presumably coming from the last operation of an earlier thread.

Another gray dotted arrow goes from the last operation of the second thread to outside the frame of the diagram, presumably to the the first operation of yet another thread.