| 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
|
 |
 |
|
|
subject: ThreadDeath on a stop( )
|
|
|