class Single6
{
private Single6(){}
private static Single6 s=null;
public static Single6 getInstance()
{
if(s==null)
{
synchronized(Single6.class)
{
if(s==null)
s=new Single6();
}
}
return s;
}
}
class SingleDemo6
{
public static void main(String[] args)
{
Single6 v=Single6.getInstance();
}
}
懒汉式加了同步代码块解决了安全隐患,那它是怎么提高效率的?没看懂 |
|