When any other thread calls the method interrupt() the thread which is sleeping gets interrupted and then the catch block is called
The output of above code is "I was in sleep and now i am interrupted...."
Hope it makes u clear, for more info look at the api
Joined: Jan 24, 2005
Hi Animesh In your program you when used t1.run(),it doesnt starts a new thread. So when i replaced it with t1.start()the program hangs.
Kindly slove it..
Joined: Jul 19, 2004
Hi Ramya, I am extremely sorry about the above program. Thats a totally wrong program. The correct one is here:
The explanation about the interrupt is explained as in API
If this thread is blocked in an invocation of the wait(), wait(long), or wait(long, int) methods of the Object class, or of the join(), join(long), join(long, int), sleep(long), or sleep(long, int), methods of this class, then its interrupt status will be cleared and it will receive an InterruptedException.
Accoridng to API, it says is that if the thread is in sleep state, and if interrupt is called on this thread, its interrupt status gets cleared and the thread is interruped Hope now its clear