Singleton.

JAVA PRIMER
Using Java Object Serialization: A Few Pitfalls
Huw Evans
Listing 5. Singleton.


public class Singleton implements java.io.Serializable
      {
         private static Singleton s = null;

         private Singleton()
         {
         }

         public static void initialize()
         {
           if(s == null)
             s = new Singleton();
         }

         public static Singleton getSingleton()
         {
           return s;
         }
      }

Featured

Upcoming Events

AppTrends

Sign up for our newsletter.

I agree to this site's Privacy Policy.