Home Here you can view your subscribed threads, work with private messages and edit your profile and preferences Registration is free! Frequently Asked Questions Search

HardwareDude.com Forum Index -> 3rd Party Software Disucssion

How do I kill a thread? The stop() method is deprecated in J


Post new topic   Reply to topic

  Author    Thread
sri
Moderator
Moderator


Joined: 28 Jan 2006
Posts: 381
Location: Hyderabad , India


 Reply with quote  
How do I kill a thread? The stop() method is deprecated in J

How to kill a thread? The stop() method is deprecated in JDK1.2, so how to shut it down?
The API documentation for JDK1.2 discusses an alternate mechanism for stopping threads, by having them continually poll a boolean flag to see if they should terminate of their own accord. This is an option, but if you have threads that become deadlocked or stall waiting for I/O, sometimes you'll have to kill them the hard way.
Why shouldn't you normally use the Thread.stop() method? Well, it is deprecated as of JDK1.2 because it can potentially leave the system in an unsafe state. If a thread had a lock on an object (within a synchronized block), it might not release the object lock, causing problems at a later time. Note that this problem can affect older JVM implementations as well, JDK1.02 and JDK1.1 are not immune
So while you shouldn't use Thread.stop() unless absolutely necessary, it is an acceptable way to kill a thread if it becomes stalled and you really need to shut it down fast.

- srikanth dhanwada

Post Wed Feb 08, 2006 10:03 pm 
 
  Display posts from previous:      



Post new topic   Reply to topic
Page 1 of 1



Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 



-Your Link Here-
Networking hardware and software solutions | web hosting directory | Web hosting and domain talk
Powered by phpBB: © 2008 HardwareDude.com | SiteMap |Privacy | Terms of Service
Powered By :