public class SingleTon {
private static SingleTon singleton;
private SingleTon() {
}
public static SingleTon getInstance() {
if (singleton == null) {
synchronized (SingleTon.class) {
if (singleton == null) {
singleton = new SingleTon();
}
}
}
return singleton;
}
}
public class SingleTon {
private static SingleTon singleton = new SingleTon();
private SingleTon() {
}
public static SingleTon getInstance() {
return singleton;
}
}
public class SingleTon {
private SingleTon() {
}
private static class Inner {
private static SingleTon t = new SingleTon();
}
public static SingleTon getInstance() {
return Inner.t;
}
}