double checked locking singleton

public static Singleton getInstanceDC() {
    if (_instance == null) { // Single Checked
        synchronized(Singleton.class) {
            if (_instance == null) {// Double checked
                _instance = new Singleton();
            }
        }
    }
    return _instance;
}


public static synchronized Singleton getInstanceTS() {
    if (_instance == null) {
        _instance = new Singleton();
    }
    return _instance;
}

Comments

Popular posts from this blog

தட்டு வண்டியில் காளிக்கோயில் - சிறுகதை

பிரேமாவின் பெண் குழந்தை

தீபம் பிளக்ஸ்