wood burning stoves 2.0*
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: 12761
    
    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
 
Don't get me started about those stupid light bulbs.
 
subject: Is it allowed to create threads inside servlets?
 
Similar Threads
New threads in J2EE application
Can We Apply User Defined Threads in EJB?
Question ID :1000056254950
Doubt abt threads in EJB
Servlets & threads