I am looking into how a synchronized and volatile variable works in java and i came across a concept called read and write barrier . Can anyone help me to understand the mea
Read and write barriers are used to implement the semantics of the Java Memory Model at the lowest level by JVMs.
However that terminology is absent from the Java Language Specification, which only reasons in terms of happens-before relationships. In particular
When a happens-before relationship exists between two actions in your program, you have the guarantee that those two actions will be executed in a sequentially consistent order (i.e. as if there were only one thread and without unintuitive reorderings).
Delving into the implementation details of the JVMs is unnecessary to write a correct multi-threaded program. However, if you want the gory details, the JSR-133 cookbook is an interesting read.