DZone
In this article, I would like to share a different approach on this subject that maybe is helpful for you, and also to talk about some particularities and misconceptions about volatile
. There`s very good material on this topic out there (like “Java Concurrency In Practice” [JCIP]). I encourage you to read it 😉
We will be talking about the semantics of volatile
as defined from Java 5 onwards (on previous Java versions, volatile has no memory-consistency/state-visibility semantic).
Java Concurrency: What Is Volatile?
Short answer: volatile
is a keyword we can apply to a field to ensure that when one thread writes a value to that field, the value written is “immediately available” to any thread that subsequently reads it (visibility feature).
Source: DZone