Monday, 28th June 2010
The new frontier for learning Java

User talk:Alcor

From WikiJava

Jump to: navigation, search

Singleton Pattern

You created the Singleton article. I have two notes:

1.) In the LazySingletonFactory example, is there a possibility that in multithreaded environment, more than one Singleton objects are created? That can happen when two thread calls the getSingletonFactory() method in the same time, and the first time. Most of the time this is not a problem, but in some cases when you must have only one instance of the singleton that should be in mind.

2.) The Lazy aspect of the examples only refers to the factory object, and not for singleton objects. Those are created right away when the factory is created

So, I would create the factory object always "normaly". And the singeleton objects could be either created normaly or lazyly. Ervinn 15:17, 2 June 2008 (PDT)

Hi Ervinn, In fact it was me to do that example. I thank you very much for your comments.

I'm copying the discussion to the talk page of the singleton article since it is more relevant there. I will reply in that page. --DonGiulio 16:30, 2 June 2008 (PDT)