?????????????????volatile???????final??????д???????????????????????final?????????????????????????????????

????1???????????????final???д??????????????????????????????????????????????????????????????

????2?????ζ????????final???????????????????ζ????final???????????????????????

???????棬????????Щ???????????????????????????

public class FinalExample {
    int i;                            //???????
    final int j;                      //final????
    static FinalExample obj;

    public void FinalExample () {     //??????
        i = 1;                        //д?????
        j = 2;                        //дf(shuō)inal??
    }

    public static void writer () {    //д???A???
        obj = new FinalExample ();
    }

    public static void reader () {       //?????B???
        FinalExample object = obj;       //??????????
        int a = object.i;                //???????
        int b = object.j;                //??final??
    }
}

?????????????????A???writer ()?????????????????B???reader ()?????????????????????????????????????????????

????дf(shuō)inal????????????

????дf(shuō)inal????????????????final???д?????????????????????????????????2?????棺

?????? JMM???????????final???д???????????????

?????? ??????????final???д?????????return???????????StoreStore??????????????????????final???д???????????????

?????????????????writer ()??????writer ()???????????д???finalExample = new FinalExample ()?????д?????????????裺

????1?????????FinalExample????????

????2???????????????????????????obj??

???????????B??????????????????????????????????????????????????????裩????????????????????