aspose file tools*
The moose likes Servlets and the fly likes Threads in Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Threads in Servlets" Watch "Threads in Servlets" New topic
Author

Threads in Servlets

James Davison
Greenhorn

Joined: Mar 28, 2004
Posts: 27
Is it acceptable to spawn a Thread to perform a background task not directly relating to providing a response to user in a Servlet? If so, are there any caveats to doing so that I should be aware of?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Certainly - it is entirely reasonable. Things to watch out for:
1. ensuring only one Thread is started
2. ensuring errors get logged
3. it is a good idea to give worker Threads a minimum priority
4. providing a way to monitor progress of really long running jobs is a good idea - why not a password protected servlet that can report the status.
This topic comes up frequently, do a search or just browse the last few weeks to find more discussion.
Bill


Java Resources at www.wbrogden.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Threads in Servlets
 
Similar Threads
error comes while connecting to database please see the source code and error for detail
Is Spring Web Services good enough?
Goods and Services Deficit Increases in March 2003
failed twice in half an hour.
Defect on Microsoft portal