What is Volatile Keyword in Java ?

The volatile keyword guarantees global ordering on reads and writes to a variable. This implies that every thread accessing a volatile field will read the variable’s current value instead of using a cached value.

By marking the variable volatile, the value of a variable is never cached thread-locally. All reads and writes will go straight to main memory of Java.



You May Interest

How Will You Use a Cookie in JSP ?

What are the Rules of Method Overloading and Method Overriding in ...

What are the Main Uses of Spring MVC Module ?

What is Observer Design Pattern in Java ?

What is the Difference Between an ArrayList and a LinkedList Data ...