本文共 1216 字,大约阅读时间需要 4 分钟。
public class Single { private static final Single single=new Single(); private Single(){} public static Single getInstance(){ return single; }}
public class Single { private static Single single; private Single(){}; public static Single getInstance(){ if(single==null){ single=new Single(); } return single; }}
public synchronized static Single getInstance(){ if(single==null){ single=new Single(); } return single;}
public class Single {private volatile static Single single;private Single(){};public static Single getIntance(){ if(single==null){ synchronized(Single.class){ if(single==null){ single=new Single(); } } } return single;}}
转载地址:http://lhdul.baihongyu.com/