Saturday, 15 June 2013

java - How to unconditionally stop a thread -


Forcing us to forcibly discontinue a thread as a best effort before we completely shut down the whole JVM needed. Typically, thread # stop has been cited as a fixedfire, even if the hammer and the dislikes do not stop unconditionally. It is not like that, though: To run yourself, all the evil thairs have to do threaddity or a superclass:

  public static zero main (string [] Args throws interrupted expeditions {Final thread T = new thread () {public void run () {for (;;) try {thread.sleep (long.MAX_VALUE); } Catch (Throttle T) {System.out.println (T.GetClass (). GetSimpleName () + "still running ..."); }}}; T.start (); Thread.Sleep (200); T.interrupt (); Thread.Sleep (200); T.interrupt (); Thread.Sleep (200); T.stop (); Thread.Sleep (200); T.stop (); }   

This will print

  the paused exception is still going on ... the interrupted exception is still going on ... Thread Deith still Running ... Thread Deith is still running ...   

Is there anything I can really do, actually complete Stop the JVM without a thread

not actually preventing a thread There is no easy way to make

delete such a method Rana,

deprecated. This method was originally designed to destroy this formula without any cleanliness. Any monitor would have been locked. However, the method was never implemented. If this was to be implemented, then the suspension would be stalled in many ways. If the targeted thread locked during the safety of an important system resource, when it was destroyed, a formula could not use this resource again. If any other thread has never attempted to lock this resource, then the deadlock will be the result. Such deadlocks usually reveal themselves as "static" processes.

Threads are not for this. They do not provide protection. Other threads can only terminate JVM - or else Gives the problematic thread to the egg

For more information, it has been deprecated. You can

No comments:

Post a Comment