Problems with design pattern "Singleton"


Blogs: Problems with design pattern "Singleton"

  1. Problems with design pattern "Singleton" (3 messages)

    The use of the design pattern "Singleton" is very common and the common implementation is using a static reference. However, according to Guy Korland, the problem with this implementation is that many times it leaves "floating garbage that is not in use." As a better solution, Joshua ben Jore has introduced WeakSingleton. This extention cleans the instance when all other references to the original instance have expired.

    Threaded Messages (3)

  2. Singleton is a commonly (mis) used design pattern. Users of this pattern should be aware of the scope & lifecycle control of the singleton object. Singleton could be at various scope levels. 1. Singleton object within a operating system environment or JVM. 2. Singleton object across clustered environments. It may not be considered singleton from application's perspective. 3. Singleton in a multi-threaded application. It should be thread safe for which programming Idioms are available.
  3. Warning: Not threadsafe[ Go to top ]

    The code given is not threadsafe and using volatile with 1.5 may not solve the problem.
  4. Warning: Not threadsafe[ Go to top ]

    Why is the above code not threadsafe? why do u think using volatile with 1.5 not solve problems?

    do u think a local variable should be used to create an instance and assign this vraiable to the other private variable?