• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads in servlets

 
dluckose
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can threads be used in servlets?
Please give me a answer
 
Kalpesh Soni
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i think so
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but since a servlet is an in-and-out type of environment (rather than running the way an executable program does), the thread would either have to run quickly enough to make the need for a thread questionable or the thread would have to be stored in a non-volatile part of the class.
For a long-running process, it's often better to run the process as a separate server task and have the servlet queue requests / get responses from there (JMS is a good way to do this). That way you don't bog down the servlet mechanism.
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dluckose, your user name does not comply to the naming standards you agreed to when you registered here http://www.javaranch.com/name.jsp . please register again with a valid user name consisting of a first name, and a last name. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic