In the below code, i have a while(true) loop.
considering a situation where there is some code in the try block where the thread is supposed to perform some tasks which take
Move the catch interrupt to outside the loop. This doesn't require any more lines of code, it just handles interrupts correctly i.e. the action is interrupted.