Will the java create objects be partially initialized?

class Singleton {
    private static Singleton instance;
    
    public int f1 = 1;   // 
    public int f2 = 2;
        
    private Singleton(){}
    
    public static Singleton getInstance() {
        if (instance == null) { // instancenull"" 
            synchronized (Singleton.class) {
                if ( instance == null ) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}

as above, does multithreading concurrency cause getIntance () to get a partially initialized object?

I read the blog post that initialization is roughly divided into three processes:
1) allocate space
2) initialize objects
3) point objects to space

and these three procedures will be reordered, causing the object to point to the space first, and returning false, when judging instance==null does not actually initialize the value of the object

doesn"t java guarantee the atomicity of instantiated objects?

Mar.21,2021
Menu