Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on Singleton

 
Rahul Sud
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Techies,

We know that Spring is by default singleton.
Now the question is How it will behave when more than two request comes at same time on the same method.How that will be handled in the by Spring.
I suppose same instance will be shared but what is the normal approach to handle that.I mean the JVM behavior for this also.

Thanks,
Rahul

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"How to handle it" depends on what it's actually doing. If there's no shared state and you're just calling methods with only parameters and local variables, there's nothing to do. If you're reading shared state that might change, or mutating shared state, something somewhere along the line would need to be synchronized, whether it's a simple collection, and entire method, etc. Totally depends.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic