File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet and threads

 
Abhijit Rai
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhijit,

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

Answer to MultiThreading of servlets
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic