java - what are read barriers and write barriers in synchronized block -


i looking how synchronized , volatile variable works in java , came across concept called read , write barrier . can me understand meaning of terms

( answers above quite complete), want demonstrate concept simple scheme

 thread 1                                                             thread 2      |              |                                                                          |                                                                      |    |                                                                      |    |  thread 1                                                 |    |   wrote before here                                                  |    |                                                                      |    |                                                                      |     _ _ _ _ _ _ _ _ _ _                                                   |       ( write  barrier)         (happens before)         (read barrier)   |    |                                                     _ _  _ _ _ _ _ _      |    |                                                   guaranteed      |    |                                                  visible    |    |                                                  thread 2            |    |                                                                      | 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -