look this mock question
Which statements regarding the following code are correct?
class A extends Thread{
public void run(){
System.out.println("starting loop");
while(true){};//(1)
System.out.println("ending loop");
}
}
public class TestClass {
public static void main(
String asd[]){
A a=new A();
a.start();
Thread.sleep(1000);
a.interrupt();//(2)
}
}
---------------------------------------
answer is
it will run and end cleanly if //(1) is replaced to while(!isInterrupted())
why it is possible?
The user
thread is interrupted at (2) it is not stopped
so how the program will quit?
can interrupt method stop a Thread??.
if interrupt can,plz tell me about interrupt() behavior