In my spring boot project , i have below GET web service
@GetMapping("/testThread")
@Transactional
public Map<String, Object> testThread(HttpServletRequest request) throws InterruptedException {
for (int i=0;i<10;i++){
Thread.sleep(3000);
System.out.println(i);
}
return null;
}
This web service i am calling from postman and inside the web service thread is starting , thread is running 10 times .
My requirement is after calling web service from postman after 10 seconds i am able to cancel that request by "Cancel Request" button, then backend thread also should be stop.
As of now its running 10 times .
Do we have any option to stop the execution of this loop in between ?