aspose file tools
The moose likes Servlets and the fly likes Servlet and threads Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Servlet and threads" Watch "Servlet and threads" New topic
Author

Servlet and threads

Abhijit Rai
Ranch Hand

Joined: Aug 07, 2008
Posts: 41
Hello people,
I had a query regarding Servlets.
We know that niether Servlet,GenericServlet or HttpServlet implements Runnable interface .My question is first ,how could a container create threads of the servlet when its not Runnable, and secondly which part of the servlet is run .


SCJP5 ,SCWCD5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35258
    
    7
"abhijit.r", it's time for you to finally adjust your display name to something valid. You've been asked to do this several times, now you're very close to getting your account closed. You should do this before your next post.


Android appsImageJ pluginsJava web charts
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35258
    
    7
As to your question, it's simple: the container creates a new thread, and from within that thread it calls the service method of the servlet.
Abhijit Rai
Ranch Hand

Joined: Aug 07, 2008
Posts: 41
I still dont get it .This thread that the container creates is it a java thread,(one in which you call start and run executes)or some other kind of thread.If its a java thread then how can the servlet class have a thread when it doesnt implement Runnable .Lastly what is executed in the new thread only service methods of servlet .
Schandha Ravi
Ranch Hand

Joined: Oct 20, 2007
Posts: 167
Hi Abhijit,

Exactly I had the same question and answered well. Probably you may want to refer this

Answer to MultiThreading of servlets


Thanks & Regards, SK
SCJP 5.0, DB2 - 800, DB2 - 803, SCDJWS (On the way)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Servlet and threads
 
Similar Threads
Servlet Container related query
When both Thread and Runnable have public void run
How the container makes thread of a servlet
Thread question
Single Thread Model