class Single
{
private static Single s = null;
private Single(){}
public static Single getInstance()
{
if(s==null)//提高效率
{
synchronized(Single.class)//同步
{
if(s==null)
//--->A;
s = new Single();
}
}
return s;
}
}
为什么加入红色标示的if(s==null)会提高效率?是什么原因促使它会提高效率?