Appendix. Rules of the Java Memory Model

Example of Synchronizes-With

JMM has the following rules:

  • An unlock operation on a monitor Synchronizes-With later lock operations
  • A write to a volatile variable Synchronizes-With later reads of the variable
  • If an action A Synchronizes-With action B, then A Happens-Before B
  • If A comes before B in program order within a thread, then A Happens-Before B

Read more in chapter 4.

Get The Well-Grounded Java Developer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.