???????Java??????
????Java???????????????????????????乲???????Java???????????????淶???????????????????????????????????Java?????????????JDK5????Java???????????????????1??????????????????????????????????У???????е???????mastingcopy????????????????????棬???????????workingcopy???????????????????????????Щ??????????????????????е?mastingcopy????????????????У???????????????????е?workingcopy?????????檔???????????8????????????????????е??????
????read??????????????????mastingcopy??????????????棬????????load??????á?
????load??????????????????read??????????洫????????????????????С?
????use??????????????????????workingcopy??????????????檔
????assign?????????????????????????????????洫??????????????С?
????store???洢??????????????????workingcopy?????????棬???????write??????á?
????write??д????????????潫??store??????????????????????????С?
????lock???????????????????????????????
????unlock????????????????????????????????


?????1 Java????????

??????????????????read???????????????У????????load?????????У?read??????load????????????????????????????????????????????????????????????????????store?????????????У????????write???????????У?store??????write?????????????????????????????????????????????????????????????Java???????Java????????б??????/д??????/?????????Volatile???????/д???????????????????Щ?????????????????????ο???JVM?淶????????????????Java???????????Щ????????????????????????????????????????????????????????????????????
?????μ?Java??????
??????JDK5?????Java????μ????????????????????????????????????????????????????????????????8??????????????????????????????????????
??????????????????????μ??????happens-before??happens-before????????LeslieLamport?????????????????????Time??ClocksandtheOrderingofEventsinaDistributedSystem???????????LeslieLamport???happens-before????????????У????????????????(partialordering)??LeslieLamport??????????и??????????????????????????????????????????????
????JSR-133???happens-before????????????????????????????????????ж???????/д????????????????????????????????????????????μ?happens-before????
?????????????????????е??????????happensbefore???????е??????????????
??????????????????????????????happens-before??????????????????
????volatile?????????????volatile???д??happensbefore??????????????volatile??????
??????????????Ahappens-beforeB????BhappensbeforeC?????Ahappens-beforeC??
????start()??????????A??в???ThreadB.start()????????B???????A????ThreadB.start()????happensbefore?????B?е??????????
????join()??????????A??в???ThreadB.join()????????????????B?е????????happens-before?????A??ThreadB.join()????????????
????????????????????????????????????????????????????JMM???????happens-before???????????????????????????????A????д????a??B?????????b??????happens-before?????????a??????b?????????????????У???JMM


?????2????????????????

?????????????a????????b?????????????????????????????happens-before???????????????happens-before????????????Java?????????????????????????????????????????????????????????????????????????????????????????????????????????????????á?