This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 12760
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
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