单例设计模式

来源:互联网 发布:部落冲突11本升级数据 编辑:程序博客网 时间:2024/06/14 13:19
public  class Test1_16
 {
private static Test1_16 t =null;
private t(){}

public static Test1_16 getInstance()
{
if (t==null)
{
synchronized(Test1_16.class)
{
if (t==null)
t=new Test1_16();
}
}
}


}
class Test 
{
private static final Test s = new Test();
private Test (){}
public static Test getInstance()
{
return s ;
}
}
0 0
原创粉丝点击