/********************************************************************* * An example of the Singleton design pattern using lazy initialization * to defer creation of the singleton object until it is first needed. *
* @author * David W. Croft * @version * 1998-04-06 *********************************************************************/ public class LazySingleton { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// private static LazySingleton lazySingleton; public static LazySingleton instance ( ) ////////////////////////////////////////////////////////////////////// { if ( lazySingleton == null ) lazySingleton = new LazySingleton ( ); return lazySingleton; } private LazySingleton ( ) { } ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// }