• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Singleton Design Pattern and Singleton Spring Bean

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Normally trees don't drive trucks. Does this tiny ad have a license?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic