单例模式
步骤:
1、构造方法私有化
2、创建私有静态变量
3、创建同步公有静态方法来返回上一步创建的静态变量来供外界调用
example:
public class A {
private A(){};
private static A instance;
public synchronized static A getInstance(){
if(instance == null){
instance = new A();
}
return instance;
}
}