1, assign the instance memory
2, Someobject constructors to initialize the member variable called
3, pointed to the instance objects allocated memory space
In the JVM instant compiler, the presence instruction reordering, in the example above, the 2 rely on 1 operation, but does not depend on 2 to 3 operation operation, that is to say, the second and the third order can't guarantee, the final execution sequence may be the 1-2-3 May be 1-2-3, so will not result in ordinary cases, get the instance is likely to be an uninitialized object references?
Don't involve multithreading, is the most common single thread instance=new Someobject () statement, can produce this kind of problem? Or am I wrong? Sincerely to solve
CodePudding user response:
Has no effect on single thread, there is no problemCodePudding user response:
No problemCodePudding user response:
List<> List=null;List=new arraylist<> (a); You can first create an object to give it a null value, then where are you? Where is the new
CodePudding user response:
Single-threaded scenarios, there is no atomic operation this Monday...CodePudding user response: