Multithreading is hard and if not coordinated and synchronized correctly it is way harder (talking about data races). This is my Infobip DevDays 2019 conference presentation where I tried to explain the Java Memory Model specification and how memory consistency is achieved.
For more details, I recommend the next couple of things to read:
- Java Concurrency in Practice 1st Edition, Brian Goetz – Besides Effective Java, a must-read for everyone dealing with Java for a living.
- Java Memory Model – Java Language Specification
- JSR 133 specification
- Java Memory Model PhD thesis (which became JSR 133 and after that official Java specification)
- Fixing the Java Memory Model
- JSR 133 (Java Memory Model) FAQ
If you find it useful, please share 🙂