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
The only way to stop an arbitrary thread is by interrupting it. Keep a reference to it then call the interrupt method.