Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Abstract Factory + Singleton -> multi-threading ?

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether combination of Abstract Factory and Singleton gives multi-threading ?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean does it automatically make something thread-safe?
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It always depends on your implementation. Design Patterns are just the clues. The are not strict.
 
kri shan
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract factory create the factories and return the sub classes from the factories. If i use singleton with Abstract factory, it controls the object creation.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still not clear on what the question is.
 
kri shan
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David, Singleton is for creating single instance per JVM. If i use Singleton with Factories will support multi-threading.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't know what you're asking; sorry. Try rephrasing the question.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

kri shan wrote:Hi David, Singleton is for creating single instance per JVM. If i use Singleton with Factories will support multi-threading.



Oh, I think I see what you mean. It's just that one thing has nothing to do with the other: one thing is multi-threaded programming (multiple Threads), and another one is a factory creating multiple objects. When you have multi-threaded programming, you have concurrency, and you should protect the integrity of the objects that suffer this concurrency (with synchronized methods, synchronized blocks, etc...). A Singleton is an object whose instance is unique, but it can be accessed by one or N Threads.
 
kri shan
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Singleton is an object whose instance is unique, but it can be accessed by one or N Threads using Factories.
Hi Robert, You are correct.
 
reply
    Bookmark Topic Watch Topic
  • New Topic