Initially, I thought that a volatile variable is better than a synchronized keyword, since it is not related to BLOCKING or CONTEXT SWITCHING. But after reading this , I am now confused.
Is volatile implemented in a non-blocking approach using low-level atomic locks or not?
A volatile implementation differs between each processor, but it is non-blocking loading / storing a field - it is usually implemented through memory gaps, but can also be controlled using cache-coherent protocols.
. Volatile vs Synchronized flow, - . Volatile , , , , , .
volatile ?
volatile . "". volatile -, . , .
volatile
, volatile .
, , BLOCKING CONTEXT SWITCHING.
, . volatile volatile , , , .
, volatile , / . . , , , . .
(synchronized) .
synchronized
, , , , , volatile, synchronized, .
Volatile Java , JVM. Volatile, , , . JVM , .
Volatile
JVM
BLOCKING , volatile, . , , " " ( ).
, volatile , , / , , , ( / JVM), .
volatile , .