servlet/background threads/long task

I

iksrazal

I'm trying to help a fellow developer on another project. The problem:

1) Tomcat 3.3, struts, web client.
2) Launch the printing of 1000 (yes, one thousand) pdf files.

So since a browser needs to recieve a response in a relatively short
period of time, the idea is to return a response immediately - after
launching background threads to complete the tasks.

My intuition is that this a really bad idea for at least one reason:

The servlet spec, as I understand it, allows a servlet container to
stop (destroy) an inactive servlet thread anytime it feels like it.

My question: what happens to background threads if the servlet is
detroyed by the container? Is this a likely scenerio in this
situation? Does the choice of daemon or non-daemon threads make the
solution any cleaner?

My immediate suggestion was to use JMS, which I myself have used a lot
in servlets but this project is a bit scared of JMS. I also have
doubts Tomcat 3.3 could support it. (I've used openJMS a lot with
tomcat 4.x).

iksrazal
 
M

marcus

Well, I have spun threads for a bingo game -- never got into production
but in testing I could make them run for weeks. I used a manager
servlet which had static variables for thread management -- IE,
killAllThreads=false/true, and each thread would periodically check the
various management variables to decide if they should keep running.

from a development standpoint, these threads are pretty easy to spin out
of control, so I used a log utility to track them starting and stopping.
Tomcat would start acting crazy and I would have to like kill -9 to
shut them all down hehe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top