On Mon, 7 Nov 2005 11:36:16 +0800 "Augmentin" <[EMAIL PROTECTED]> wrote: >Hi, > >I found that the daemon threads created by my Tomcat >webapp won't automatically stop when the webapp itself is >stopped or undeployed/redeployed. > >As Tomcat itself is a java application there will always >be user threads in the jvm even when your webapp is >stopped.. which makes the daemon threads spawned by >webapps never stop. > >I tried to add a finalize() method to a main object in the >webapp to interrupt the daemon threads but it didn't seem >to work... the timing of call to finalize() is >undetermined, only when it performs garbage collection. >And many times it seemed that when my webapp is >stopped/reloaded/undeployed/redeployed the objects were >just not properly finalized or garbage collected at all. > >I am using Tomcat 5.5.9 on Windows XP Pro and Solaris 2.6. > >Thank you for your help. >Raymond.
When you create new thread you would define a stopping clause, some way to terminate your thread at any given time when requested. Next you would add all your threads to a 'holder' that would 'know' what threads are alive. Finally you can create an Application Serlvet Context Listener, an in Destroy method you can iterate through all elements in the 'holder' and call/invoke your stopping parameter on all threads. That should work. DarekC --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]