How much time does a Thread need to stop/disappear after its interrupt() method has been called?
Consider the following code:
public class MyThread {
    public boolean flag = true;
    public void run() {
        while(flag) {
            doSomething();
            Thread.sleep(20);
        }
    }
}
void foo() {
    MyThread t = new MyThread();
    t.start();
    Thread.sleep(100);
    t.flag = false;
    t.interrupt();
}
Does the assignment t.flag = false; have any effect? In other words, can a thread exit its run() method and terminate "normally" before it is interrupted?
 
     
    