/**
 * example of a singleton class with threadsafe lazy instantiation
 * @author Chris Smith
 */
public class MySingletonClass
   {
   /**
    * get handle to the singleton
    * @return the singleton instance of this class.
    */
   public static MySingletonClass getInstance()
      {
      return instance;
      }

   /**
    * singleton instance
    * created when class is loaded.
    */
   private static MySingletonClass instance = new MySingletonClass();

   /**
    * private constructor, prevents direct instantiation of this class.
    */
   private MySingletonClass()
      {
      }

   ...
   }