----- Original Message ----- 
From: "Endre Stølsvik" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 12, 2001 10:50 AM
Subject: Re: Killing endless loop servlet - howto ? killing JVM or unload class ?


> On Thu, 12 Jul 2001, Dmitri Colebatch wrote:
> 
> | On Thu, 12 Jul 2001 16:28, you wrote:
> | > I thought the problem with threads was that you actually _cannot_ kill
> | > them, even "in Java". I find this stupid, and hope I'm wrong! But
> | > apparently you can only "ask" the thread to interrupt and check for status
> | > by using the thread.interrupt(), and isInterrupted() inside the thread.
> | The purpose of this is to force a two-phase termination, and give the thread
> | a chance to clean up... its up to the thread programmer to be aware of any
> | requests for interruption.  When you say you can only "ask", you are correct.
> |  I dont see why this prohibits my earlier suggestion though...
> 
> How would you stop this thread?
> 
> while(true);
> 
> 
> -- 
> Mvh,
> Endre
> 

Hi!

public booelan running;


public void run(){
    while(running){
    }
}

Another thread can then stop the thread by altering running to false. Then the thread 
will have the possibility to clean after itself.

You must ofcourse register the tread somewhere so you can find it but that is another 
question. Perhpas something to implement at serverlevel so a admin can look for 
running threads and kill them off...????

Regards
Roland Carlsson



Reply via email to