PDA

View Full Version : Threads and Servlets


_underdog
08-13-2002, 03:17 PM
I have a web application that has to perform an action that takes a long time (reloading a database table) and should be performed in a Thread. I spawned a new thread so that the user could continue on while the long action was being performed. This seems like it should work fine, but sometimes the server locks up and when I shut down the server it usually hangs up on shutdown. I am using Tomcat4.0. Is there a better way to handle this situation? How should threads be managed on a Server? Anyone tried to do something like this before?

Bradmont
08-13-2002, 03:29 PM
Are you running your threads as daemon threads? Maybe try that, it might help.

_underdog
08-13-2002, 03:35 PM
I have a class that extends Thread and then I call:

myThread.run();

Am I missing something... Is there something I need to do to make it a daemon?

Bradmont
08-13-2002, 05:22 PM
myThread.setDaemon(true);

you have to do this before you call the thread's run method.