This is a short article to give you a taste of the Java Memory Model. Being unaware of its rules can lead to some pretty knotty bugs. Any serious Java developer who wishes to write thread-safe parallel programs should be aware of the memory visibility issues that arise due to the JMM.

What Is a Memory Model?

Any modern computer architecture can do such things like cache global variables and reorder instructions to get a performance boost. It is not guaranteed that the instructions are run in the order as they were written in the high-level program. In a single…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store