public class Singleton{
private static final Singleton singleton;
private Singleton(){
}
public static final synchronized Singleton getInstance(){
if(singleton==null){
singleton=new Singleton();
}
return singleton;
}
}
public class Singleton{
private volatile static Singleton singleton;
private Singleton(){
}
public static final Singleton getInstance(){
if(singleton==null){
synchronized(Singleton.class){
if(singleton==null){
singleton=new Singleton();
}
}
}
return singleton;
}
}
public class Singleton{
private Singleton(){
}
private static class Holder{
public static final Singleton singleton=new Singleton();
}
public static final Single getInstance(){
return Holder.singleton;
}
}
public class Singleton{
private static final Singleton singleton=new Singleton();
private Singleton(){
}
public static final Singleton getInstance(){
return singleton;
}
}
public class Singleton{
public enum EasySingleton{
INSTANCE;
}
}