单例模式
//单例模式
public class SimpleDemo {
private static SimpleDemo instance;
private SimpleDemo (){}
public static SimpleDemo getInstance(){
if (instance == null){
synchronized (SimpleDemo.class){
if (instance == null){
instance = new SimpleDemo();
}
}
}
return instance;
}
}
网友评论