I just wanted to know if the following numbers are valid or not in the new JMM
Original Code: instanceVar1 = value ;// normal read operation, no volatile synchronized(this) { instanceVar2 = value2; //normal read operation, no volatile } instanceVar3 = value3; //normal read operation, no volatile
The above code can be reordered into the following executions.
Case 1: synchronized(this) { instanceVar2 = value2; //normal read operation, no volatile instanceVar1 = value ;// normal read operation, no volatile } instanceVar3 = value3; //normal read operation, no volatile
Another case:
Case 2: synchronized(this) { instanceVar3 = value3; //normal read operation, no volatile instanceVar2 = value2; //normal read operation, no volatile instanceVar1 = value ;// normal read operation, no volatile }
Another case:
Case 3: instanceVar3 = value3; //normal read operation, no volatile synchronized(this) { instanceVar2 = value2; //normal read operation, no volatile instanceVar1 = value ;// normal read operation, no volatile }
Another case:
Case 4: instanceVar3 = value3; //normal read operation, no volatile synchronized(this) { instanceVar2 = value2; //normal read operation, no volatile } instanceVar1 = value ;// normal read operation, no volatile
All 4 cases listed above are valid for reordering source code in the new JMM model. I gave all the above reorders based on my understanding of http://gee.cs.oswego.edu/dl/jmm/cookbook.html
source share