tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mufaddal Khumri <mufad...@wmotion.com>
Subject Re: HOW CAN I USE THREADS IN TOMCAT
Date Mon, 03 Nov 2003 04:18:39 GMT
Hi,

The problem is that stop / suspend are deprecated. The destroy() method 
has yet not been implemented ? What does one do then?

I have a solution -

Keep a reference to the instances of the threads spawned in a 
hashtable. In contextDestroy make all these references null . Will this 
solution work ?

Thanks.

On Monday, November 3, 2003, at 09:27  PM, Shapira, Yoav wrote:

>
> Howdy,
>
>> I have an instance of MyMailScheduler - mmsched in a ContextListener
>> class for my webapp. mmsched spawns threads to do some work regarding
>> sending emails. In my contextDestroy method I do : mmsched = null;
>
> mmsched should have a close()/stop()/shutdown() method which stops its
> threads.  You call this method, and then set mmsched to null.
>
>> I was under the impression that if tomcat was shutdown or the webapp
>> was stopped my threads would be automatically killed since mmsched
>> would be garbage collected. Am I understanding this right or do I need
>> to do something else ?
>
> The JVM can't stop non-daemon threads.  Either make mmsched spawn 
> daemon
> threads, or make the mmsched stop() method interrupt and stop all its
> threads.
>
>>  My webapp does two mail related tasks for two different sets of data.
>> Both tasks are identical and therefore I spawn two threads. The two
>> threads do not share any data structures. Also do I need to make the
>> run() method synchronized ?
>
> You don't need to make the run() method synchronized.
>
> Yoav Shapira
>
>
>
> This e-mail, including any attachments, is a confidential business 
> communication, and may contain information that is confidential, 
> proprietary and/or privileged.  This e-mail is intended only for the 
> individual(s) to whom it is addressed, and may not be saved, copied, 
> printed, disclosed or used by anyone else.  If you are not the(an) 
> intended recipient, please immediately delete this e-mail from your 
> computer system and notify the sender.  Thank you.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message