• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

background process on tomcat 4

 
Ariffin Ahmad
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic