will join() method also throw InterruptedExceptoin like sleep() method?
yes join() method also throws InterruptedException like sleep() method do. Programmer has to handle it by putting join() method in a try-catch block.
The reason for join() method throwing InterruptedException is, once we call join() method our thread will go to suspended or blocked state, until other thread is finished. While our thread is in suspended state, there may be a chance that other threads will interrupt our thread.
Back To Top