Hi Rufus,
Originally quoted by Rufus BugleWeed:
"allowing the flexibility to create more objects if the situation changes"
is true and may be usefull in those situation mentioned in that article, but in my opinion this leaves the singleton pattern then and goes to another [which one?] usefull design pattern.
Originally posted by Rufus BugleWeed:
When is a Singleton Not a Singleton?
Thank you for that link, really interesting.
Especially the following sentence of that article was very interesting to me:
Originally _quoted_ by Rufus BugleWeed:
"The only practical solution is to synchronize the getInstance() method"
i.e.:
public static synchronized MySingleton getInstance() { ...
because I would not have trusted a static methad to synchronize. I would have missed the object on which to synchronize its methods. But that was just the coarsest way of synchronization (instead of on methods themselfes).
Good old Flanagan "Java in a Nutshell" (1.0!), page 161:
using synchronized to prevent access by multiple threads to critical data structures
- not only to critical objects allowing to be referenced by "this".
Flanagan "Java in a Nutshell", p. 46:
synchronized: ... mark[s] a critical section of code. The same keyword can also be used as a modifier for class or instance methods.
Thomas.