As we know, when servlet receivies a request, it creates a new thread and inside the new thread, the service method is invoked. So with only one Servlet instance, many threads are invoked.
What I didn’t understand is how HttpServlet is able to create threads of its own instance without implementing runnable or extending thread?
Can any one please clarify.
In fact, that is INCORRECT. The web container typically maintains a bounded pool of worker threads to handle requests. New threads don’t get created for each new request.
Basically, it doesn’t.
HttpServletdoes not create threads, and it is not a thread or a runnable.The web container has implementation specific classes that implement
Runnableor extendsThread. These classes call the relevant methods on the (shared)Servletinstance.