本帖最后由 空洞的望着窗外 于 2015-3-15 11:28 编辑
class Single{//饿汉
private Single(){}
private static final Sinagle s=new Single();
public static Single getSingle(){
return s;
}
}
//懒汉
class Single{
private Single(){}
private static Single s=null;
public static synchronized Single getSingle(){
if(s==null)
s=new Single();
return s;
}
} |