本帖最后由 汗血黑马 于 2014-3-28 19:36 编辑
class Single
{
private static Single s =null;
private Single(){}
public static Single getInstance()
{
if(s==null)
{
synchronized(Single.class)
{
s = new Single();
}
}
return s;
}
}
class SingleDemo
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
} |
|