デュアルチェックの単一モード

1725 ワード

package com.loujin.utils;

/**
 *  volatile 
 * @author jin
 *
 */
public class SaveDoubleCheckLocking {
    
    private volatile static SaveDoubleCheckLocking instance;
    public static SaveDoubleCheckLocking getInStance(){
        if(instance==null){
            synchronized (SaveDoubleCheckLocking.class) {
                if(instance==null){
                    instance = new SaveDoubleCheckLocking();
                }
            }
        }
        return instance;
    }
}