File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How the container makes thread of a servlet

 
tarik el berrak
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

I belive there is only one instance of each servlet which the container instantiate and initilaize...
But how the container makes threads of this servlet instance ( accorind the to API, GenericServlet doesn't extends Thread class and doesn't implement Runnable interface and it's the same for its subclass HttpServlet).
Any clarifications will be welcome

Thanks in advance
 
tarik el berrak
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No body can help ?
 
Phani Burra
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tarik,

Good question. As far as creating the threads to handle the requests is concerned it is the job of the container and not the servlet. That is why you wont find either the Servlet or the GenericServlet extending Thread or implementing the Runnable. An example of a container is Tomcat. Tomcat is a multi-threaded servlet container meaning if a new request comes in, after creating the instance of the servlet tomcat would create a thread or use one of its threads in the pool and assign it the corresponding request. So the thread management logic of creating the threads and destroying them is present in the container.

I hope it gives you some idea.
 
kalle suresh
Ranch Hand
Posts: 48
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic