1.懒汉式
public class jetlag{
private static Jetlag jetllag = null;
priavte Jetlag(){}
private static Jetlag getJetlag(Jetlag jetllag){
if(jetllag == null){
jetlag = new Jetlag();
}
return jetlag;
}
}
2.饿汉式
public class Jetlag{
private static Jetlag jetlag= new Jetlag();
private Jetlag(){}
public static Jetlag(){
return jetlag;
}
}
3.变种的饿汉式
public class Jetlag{
private statci Jetlag jetlag = null;
static {
jetlag = new Jetlag();
}
private Jetlag(){}
public static Jetlag(){
return this.jetlag;
}
}
网友评论