I have a thread, and on run()
I call sleep()
. What will happen if I interrupt this thread?
MyThread extends Thread{
public void run(){
try{
sleep(1000000);
} catch(InterruptedException e) {//}
}
}
I want to clarify the following:
- If the thread is not yet started, calling
interrupt()
would do nothing, right? - If the thread is started, and is now sleeping, calling
interrupt()
while sleeping will throw anInterruptedException
; and thus, goes tocatch()
and then ends the thread, right?