File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes ThreadDeath on a stop( ) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "ThreadDeath on a stop( )" Watch "ThreadDeath on a stop( )" New topic
Author

ThreadDeath on a stop( )

Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 645
I'm calling the stop() method on a running thread. I'm not really bothered about recovery of the state of the task being performed on that thread. I'm getting a ThreadDeath error thrown. I've gone through the thread API documentation and it recommended not to catch the error. I'm following suit.

My question is, is it safe from a JVM standpoint to ignore this error and continue with other tasks in the system, i.e., is calling stop() going to cause any instability in the system?

Can someone please throw some light on this?

Thanks.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
You presumably know that stop() is strongly deprecated. You really shouldn't be calling it. Why do you think you need to call it?

Assuming you're in the 0.1% of people who really need to call it, not the 99.9% who only think they do, but could actually do something different and much better, then it sounds like you're handling it as correctly as it is possible to handle something you shouldn't do in the first place. You certainly should not catch the ThreadDeath.

My understanding is that calling stop() will not break the JVM itself. It only risks fouling up any objects used by that thread, which may also be used by other threads. It is very difficult to be sure there are no such objects. Even if there are none in your code, can you be sure there are none in API code on which you implicitly depend?


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ThreadDeath on a stop( )
 
Similar Threads
Not Clear about Interrupt
Daemon Threads
why it prints the statement in wrong order or fashion?
is CloneNotSupportedException Checked Exception.
what's with the ThreadDeath