public class Hello {
static volatile int a;
public static void main(String[] args) {
a=200;
a=100;
a=a+1;
}}
the byte code are below
0 sipush 200
3 putstatic #2 <jvm_test/Hello.a>
6 bipush 100
8 putstatic #2 <jvm_test/Hello.a>
11 getstatic #2 <jvm_test/Hello.a>
14 iconst_1
15 iadd
16 putstatic #2 <jvm_test/Hello.a>
19 return
the a=200 composed by sipush 200 and putstatic #2 instead of one operation. so, why we say this is atomic