What Does Volatile Mean?

Volatile is a keyword within the java programming language that specifies that a member variable associated with a class can be altered asynchronously by multiple threads. The volatile keyword in the code acts as a modifier when a member is declared. Keywords are fundamentally reserved words with a distinct meaning in the context of a compiler.

Techopedia Explains Volatile

The volatile keyword ensures that each read access to a member variable returns the most recent value of it. This is not effective when the recent changes are done using a different thread. If a member variable is not declared as volatile, a thread will not be able to recognize the modifications done to it using a different thread.