package cn.sigangjun.project;
/**
* @author sigangjun
*
*/
public class SingtonTest {
private static SingtonTest instance = null;
private SingtonTest(){};
public static SingtonTest getInstance(){
if(instance==null){
synchronized (SingtonTest.class) {
if(instance==null){
instance=new SingtonTest();
}
}
}
return instance;
}
}
线程并发时,防止单例出现多个实例。
最新推荐文章于 2022-09-09 13:36:07 发布