What? Why? Where? When? Which?
What? Why? Where? When? Which?
Stephan van Hulst wrote:
It's good to understand the pattern, but never use this in real life, no matter how pervasive this anti-pattern is in online articles.
What? Why? Where? When? Which?
Dave Tolls wrote:Not sure I'd call it an anti-pattern, as it doesn't make anything worse than a regular singleton would.
Rajeev Pedada wrote:I just want to reuse the same object(DBService) instead of creating every time on every thread call.
Dave Tolls wrote:
Stephan van Hulst wrote:
It's good to understand the pattern, but never use this in real life, no matter how pervasive this anti-pattern is in online articles.
Not sure I'd call it an anti-pattern, as it doesn't make anything worse than a regular singleton would.
It's just pointless, and shows a lack of understanding of how Java loads classes.
Junilu Lacar wrote:
I doubt that Bill Pugh had anything but a very good understanding of how Java loads classes. His work influenced changes to Java Memory model after all.
Stephan van Hulst wrote:I'm not sure what you mean Dave. The code in the very first post is the best way to instantiate globally accessible objects only on demand. It only works reliably under the Java 5+ memory model.
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|