there is some problem in this code, its not getting executing. but when i am uncommenting the finally block, its just printing the "complete" without printing "holas" , Any idea?
import java.util.ArrayList;
import java.util.List;
public class MyThread {
/**
* @param args
*/
public static boolean interruptTask=false;
public static class D extends Thread{
public void run(){
while(!interruptTask){
System.out.print("Hello");
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Thread task = new D();
task.start();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
interruptTask=true;
try {
task.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}/*finally{
System.out.println("holas");
}*/
System.out.println("complete");
}
}