• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

can we have more than one instance of a servlet at container start up

Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi gyes.. I have a little doubt...
As the life cycle of servlets says that the container will create one instance per servlet at startup or when the 1st request comes up for the servlet. If other requests come in by that time the container will see if there is any intance of that servlet is existing if its there than a new thread will be processing the second request.. and same for other request also.. Now if my servlet is to be designed to handle 1000 request at a time.. will there be 1000 therads processing the request on behalf of Only single instance of that servlet or we can have different concept to do that..(as far as i know instance pooling is available only for the servlet which implements Single Thread Model)...
Thanx in advance....
[ March 01, 2004: Message edited by: Bis Bang ]
Posts: 7001
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, there would be 1000 threads running through a single servlet at the same time, but this is a good thing! Think how quickly your server would run out of memory, if there was a separate servlet for each request.
It's a common misunderstanding, but believe me, you don't need separate instances to make your application go faster. Each thread only needs to read the servlet code, and lots of threads can be reading the same code at the same time.
An anology I have used before is that of a movie theater. You don't expect the movie to take longer just because a few more people come in to see it today.
Does that make sense?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic