Correct a double-checked locking pattern

Report a typo

Fill in the gaps (1) and (2) to make this double-checked locking pattern correct.

public class Singleton {
    private static (1) Singleton singletonObject;

    public static Singleton getInstance() {
        if (singletonObject == null) {
            (2)(Singleton.class) {
                if (singletonObject == null) {
                    singletonObject = new Singleton();
                }
            }
        }

        return singletonObject;
    }
}
Select one option from the list
___

Create a free account to access the full topic