1.

What Is Volatile In Java?

Answer»

VOLATILE is a special modifier which is used to indicate that a variable’s value will be modified by different threads. The volatile keyword will mark a Java variable as “being stored in main memory”. The value of this variable will never be cached locally: all reads and WRITES will go straight to “main memory”. Volatile variable GUARANTEES that a write will happen before any subsequent read. Access to the variable ACTS as THOUGH it is enclosed in a synchronized block.

volatile is a special modifier which is used to indicate that a variable’s value will be modified by different threads. The volatile keyword will mark a Java variable as “being stored in main memory”. The value of this variable will never be cached locally: all reads and writes will go straight to “main memory”. Volatile variable guarantees that a write will happen before any subsequent read. Access to the variable acts as though it is enclosed in a synchronized block.



Discussion

No Comment Found