hi there,
hope that u all r fine.here is the programme which has a output which i dont expect so please help me out.
class Threads extends Thread{
public void run(){
System.out.println(Thread.currentThread()+"is going to start");
try{sleep(1000);
}catch(InterruptedException e){
System.out.println("Exception in"+Thread.currentThread()+" was Caught");
}
}
}
class TestThreads{
public static void main(
String []args){
Threads[] t1={ new Threads(),new Threads()};
for (int i=0;i<t1.length;i++){
t1[i].start();
//t2.start();
t1[i].interrupt();
System.out.println(t1[i]+" is interrupted:-"+t1[i].isInterrupted());
}
}
}
/*output:
Thread[Thread-0,5,main] is interrupted:-true
Thread[Thread-1,5,main] is interrupted:-true
Thread[Thread-0,5,main]is going to start
Thread[Thread-1,5,main]is going to start
Exception inThread[Thread-0,5,main] was Caught
Exception inThread[Thread-1,5,main] was Caught
question :-
my question is that why interrupted statement comes first,rather it should come later?
hope that you ppl would help me out.
thanks in advance
with regards
kumar abhay*/