• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

background process on tomcat 4

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?.....
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)?.....
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic