aspose file tools*
The moose likes Servlets and the fly likes background process on tomcat 4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "background process on tomcat 4" Watch "background process on tomcat 4" New topic
Author

background process on tomcat 4

Ariffin Ahmad
Ranch Hand

Joined: Aug 16, 2001
Posts: 84
i have 1 servlet which will run a thread, background process, whenever the init() on that servlet called. i tried on tomcat 3.3a and tomcat 3.2.3, and both tomcat will run my servlet's background process, will run the thread. but, when i run the servlet using tomcat 4, tomcat 4 will run the init(), but when it do not start the thread. what happen?... i used the same code, servlet, on tomcat 3.2.3, 3.3a and 4....
can anyone explain it to me?.....
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
There should be no difference between the Tomcat versions with respect to running a "Background" Thread. What priority do you set for the Thread?
Bill
Ariffin Ahmad
Ranch Hand

Joined: Aug 16, 2001
Posts: 84
Originally posted by William Brogden:
There should be no difference between the Tomcat versions with respect to running a "Background" Thread. What priority do you set for the Thread?
Bill

well, i 'magically' work now...
but, i still can't understand why....
i used the same servlet, and the same web.xml on tomcat 3.2.3, 3.3a and 4.0.2....
but, i just notice, the higher priority in tomcat 4.0.2 is 1 not 0 as in 3.2.3 and 3.3a, is it true?.......
Ariffin Ahmad
Ranch Hand

Joined: Aug 16, 2001
Posts: 84
Originally posted by William Brogden:
There should be no difference between the Tomcat versions with respect to running a "Background" Thread. What priority do you set for the Thread?
Bill

and, what will happen to the background if i set the setDaemon(true)?.....
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Will make your thread a daemon thread, i.e. a "helper" thread. It will die once the thread that spawns it dies. Please note you cannot call this method on a thread that has already started else it will throw an IllegalStateException.
-anthony
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
NO NO NO - the following is totally wrong
Will make your thread a daemon thread, i.e. a "helper" thread. It will die once the thread that spawns it dies.

Where do these ideas get started???
Threads do not have the concept of a "parent" Thread. Daemon threads will die when the entire JVM is closed down or when they exit the run method like other Threads.
Bill
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Sorry, my mistake
A daemon thread dies when all user threads have stopped running, whether or not the daemon thread has finished its run() method. Of course, the daemon thread dies if it finishes its run() method earlier than that...
-anthony
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: background process on tomcat 4