Singleton Implementation in flex

package scriptFiles
   public class Singleton
      private static var INSTANCE : Singleton
      public function Singleton(enforcer:SingletonEnforcer)
      { // construction }
      private static function getInstance(): Singleton
         if(INSTANCE == null)
            INSTANCE = new Singleton(new SingletonEnforcer());
         return INSTANCE;
* Constructor
* Dummy private class to enforce Singleton.
class SingletonEnforcer{}


1 Comment »

  1. 1
    Gaurav Says:

    Hey man,

    How will you hadle multi threading here? I dont know much about FLEX but i dont think this code will work if you have multi threaded application.

    Correct me if I am wrong?


RSS Feed for this entry

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: