packageidv.design.pattern.singleton.laztinitholder;/** * @author Carl Lu */publicclassSingleton {privateSingleton() { }publicstaticSingletongetInstance() {returnSingletonHolder.instance; }/* * An inner class that with no any binding relationship with outer class instance, * this class will be loaded only when invoked, so it can also reach the goal of lazy loading. */privatestaticclassSingletonHolder {/* * Initialize it statically and guaranteed thread safe by JVM */privatestaticSingleton instance =newSingleton(); }}