public class Test {
private volatile Test instance= null;
private Test(){}
public static Test getInstance(){
if(instance == null ) {
synchronized(Test.class) {
if(instance==null) {
instance = new Test();
}
}
}
return instance;
}
}
原文:http://www.cnblogs.com/cici20166/p/5554750.html