线程安全的单例模式
/**
* @author z_hou
* @create 2019-07-05-11:16
*/
public class BankTest {
}
class Bank{
//私有化构造器
private Bank(){}
private static Bank instance = null;
public static Bank getInstance() {
if(instance == null){
synchronized (Bank.class){
if(instance == null){
instance = new Bank();
}
}
}
return instance;
}
}