双重检查锁定的单例模式

  Double Check Lock(DCL模式):双重检查锁定

public class BasicDateEntity {
     private  static BasicDateEntity basicData;
        public static BasicDateEntity getSingle() {
            if(basicData == null) {
                synchronized (BasicDateEntity.class) {
                    if(basicData == null) {
                        basicData = new BasicDateEntity();
                    }
                }
            }
            return basicData;
        }

List liststring;

public List getListstring() {
            return liststring;
        }
        public void setListstring(List liststring) {
            this.liststring = liststring;
        }

}

你可能感兴趣的:(双重检查锁定的单例模式)