Tuesday, May 11, 2010
final answer to lazy initialization of Java singleton object
main idea: let Java JVM do the synchronization
static class SingletonContainer{
private static Singleton singleton = new Singleton();
public static Singleton getInstance(){
return singleton;
}
}
http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom