This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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.