Assume that I have two threads thread1, and thread2. thread2 is sleeping and thread1 is trying to interrupt thread2. Now what will happen to thread1 which is sleeping?
Nothing will happen, thread1 continues to sleep.
thread2 will get suspended and will be moved to blocked state.
thread1 will be interrupted and gets InterruptedException and it comes out of sleep mode.
thread1 will get InterruptedException and immediately thread2 will go to sleep mode.
If a thread is sleeping and other threads interrupts it, then the sleeping thread will be interrupted and comes out of sleep mode.
So, thread1 will be interrupted and gets InterruptedException and it (thread1) comes out of sleep mode.
Back To Top