File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads in Servlets

 
James Davison
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic