-
Problems with design pattern "Singleton" (3 messages)
- Posted by: Regina Lynch
- Posted on: July 28 2006 11:25 EDT
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)
- Singleton Pattern's possible pitfalls by Swapnil Jagtap on August 09 2006 05:30 EDT
- Warning: Not threadsafe by James Watson on September 11 2006 11:27 EDT
- Warning: Not threadsafe by A C on June 19 2010 01:27 EDT
-
Singleton Pattern's possible pitfalls[ Go to top ]
- Posted by: Swapnil Jagtap
- Posted on: August 09 2006 05:30 EDT
- in response to Regina Lynch
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. -
Warning: Not threadsafe[ Go to top ]
- Posted by: James Watson
- Posted on: September 11 2006 11:27 EDT
- in response to Regina Lynch
The code given is not threadsafe and using volatile with 1.5 may not solve the problem. -
Warning: Not threadsafe[ Go to top ]
- Posted by: A C
- Posted on: June 19 2010 01:27 EDT
- in response to James Watson
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?