Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Singleton Design Pattern and Singleton Spring Bean

 
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

The doubt that I have is, is the Singleton Design Pattern and the Singleton Bean in Spring are the same or different. I just googled for this and some posts say that they are totally different. Any thoughts on this as well?
 
Joe Harry
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there new threads that are spawned for each requests to the Singleton bean in Spring? Something like the service method in Servlets???
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what a "request to a singleton bean" is.

A singleton bean follows the singleton pattern--there's only one instance.

I guess I'm not really sure what you're asking.
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are quite different.
GoF Singleton class will have only one instance per ClassLoader, whereas for Spring Singleton the only one instance will be created per container and per bean.
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jothi Shankar Kumar wrote:Are there new threads that are spawned for each requests to the Singleton bean in Spring? Something like the service method in Servlets???


It depends on that you (or servlet container or any code) create a new thread or not. Spring Framework doesn't create new thread.
 
Joe Harry
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kengkaj Sathianpantarit wrote:

Jothi Shankar Kumar wrote:Are there new threads that are spawned for each requests to the Singleton bean in Spring? Something like the service method in Servlets???


It depends on that you (or servlet container or any code) create a new thread or not. Spring Framework doesn't create new thread.



What do you mean here? If I need I can create a new servlet thread?? The servlet specification says that for each request, the container creates a new thread starting from the service method. So I though for the Singleton Spring beans, Spring would be doing something like that...
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jothi Shankar Kumar wrote:

Kengkaj Sathianpantarit wrote:

Jothi Shankar Kumar wrote:Are there new threads that are spawned for each requests to the Singleton bean in Spring? Something like the service method in Servlets???


It depends on that you (or servlet container or any code) create a new thread or not. Spring Framework doesn't create new thread.



What do you mean here? If I need I can create a new servlet thread?? The servlet specification says that for each request, the container creates a new thread starting from the service method. So I though for the Singleton Spring beans, Spring would be doing something like that...


I mean if servlet container create a new thread, there will be a new thread. Spring doesn't create a new thread.

I just rephrase my answer. I wonder what makes you think Spring will create a new thread.
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic