How do I override a Thread's stop() method when its final OR How do I safely stop a Thread
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ynoT_Tony
Posted On:   Wednesday, July 24, 2002 08:53 AM

I am trying to safely stop a Thread using the below reference.
http://java.sun.com/j2se/1.3/docs/guide/misc/threadPrimitiveDeprecation.html

However,
first I CANT override the stop() method of my thread and thus I cant comply.
Second I try to change the method name to something like "terminate", it compiles,
but then when as soon as I try calling the terminate method of my Thread, I get a NullPointerException,
and this doesnt stop my thread either.

Would someone please tell me how to safely stop a thread with no exceptions and of course be compilable?

Thanks.
Tony

Re: How do I override a Thread's stop() method when its final OR How do I safely stop a Thread

Posted By:   Simon_Ablett  
Posted On:   Wednesday, July 24, 2002 09:04 AM

Either set a semaphore in the thread and then poll for it within the thread or call 'interrupt' and catch the 'InterruptedException' (and possibly 'InterruptedIOException' under Solaris).

Regards.
About | Sitemap | Contact