I am trying to understand the following paragraph about volatile variables in java. (from section 3.1.4 of Java concurrency in practice):
"The visibility effects of volatile variables extend beyond the value of the volatile variable itself. When thread A writes to a volatile variable and subsequently thread B reads that same variable,the values of all variables that were visible to A prior to writing to the volatile variable become visible to B after reading the volatile variable. So from a memory visibility perspective, writing a volatile variable is like exiting a synchronized block and reading a volatile variable is like entering a synchronized block."
Why writing to a volatile variable by A and reading the same variable by B makes other variables visible to B? Is it because volatile acts as a barrier?