aspose file tools*
The moose likes Servlets and the fly likes Is it allowed to create threads inside servlets? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Is it allowed to create threads inside servlets?" Watch "Is it allowed to create threads inside servlets?" New topic
Author

Is it allowed to create threads inside servlets?

Qand Davaatsedev
Ranch Hand

Joined: Feb 06, 2002
Posts: 36
Hi,
Is it allowed to create threads or schedule Timers inside servlets?
Thanks.


Qand
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
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.


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
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
 
wood burning stoves
 
subject: Is it allowed to create threads inside servlets?