验证中...
10月20日,北京【人工智能】源创会火热报名中,点击报名收获 AI 训练指南
gistfile1.txt
Raw Copy
public class Test {
}
/**
* 多线程的单例,考虑性能
* 确保单例
* @author Administrator
*
*/
class Singleton {
private static volatile Singleton singleton =null;
/**
* 双重if检查锁
* @return
*/
public static Singleton getInstance(){
//不管来几次 都要同步
if(singleton==null){
synchronized(Singleton.class){
if(singleton ==null){
singleton = new Singleton(); //
}
}
}
return singleton;
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search