class Student{
private int age;
private static Student s=new Student;
private Student(){}
public static getStudent();
{
return s;
}
public void setAge(){
this.age=age;
}
public int getAge(){
return age;
} // 饿汉式
class Single{
private static Single s=null;
private Single(){
}
publuic static SinglegetInstance(){
if(s==nul)
s=new Single(); 懒汉式 怎么解决 线程的问题???????
return s;
}
}//懒汉式
} |