• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it allowed to create threads inside servlets?

 
Qand Davaatsedev
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it allowed to create threads or schedule Timers inside servlets?
Thanks.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's allowed in that technically you can do it.
However it isn't very advisable. Generally your servlet should be serving something up as a response to a request. If there are other tasks that need to be done you probably want them to be done outside of the servlet container, such that if the container has problems, or is restarted etc then your other tasks can carry on.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using one servlet request to start a Thread that does some long process is quite common, but the servlet needs to complete a response - not wait on the long process.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic