I read a document which say Volatile Modifiers, are not cached by the JVM. When ever a volatile variable value is required by a
thread it will access directly from the variable itself (without using the JVM cache)..
Volatile: Volatile modifier tells the compiler that the variable modified by
volatile can be changed unexpectedly by other parts of the program. For
example a Variable might be read from Cache and not update the content if it
has been changed by another thread. Specifying a variable as volatile tells
the JVM that any threads using that variable are not allowed to cache that
value at all. Making the Variable Volatile will ensure that the compiler
will get the content of the variable every time it is used and not cache its
content. If not used Carefully this modifier might introduce bugs..
is my understanding is right ???... can you please share me in which real time scenarios we will use volatile modifiers....