Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlets multithreading concept doubt

 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
is it always that no matter how many requests come from different clients for one particular SERVLET instance only new threads are created to serve it??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pretty much, yes. There's wiggle room in the Spec (unless that's changed) for containers to create multiple instances as they see fit, but from the developer's point of view, your code needs to be written so that multiple threads can access a single servlet instance.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh you mean to say that we can create more then one instance of the same servlet which can serve different clients also. so this is also a possibility.

But in mormal situations only one instance is loaded and it creates multiple threads to serve clients.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As developers you have little control over the inner workings of the container, but yes, assume a single instance is created.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic