Issue
I am using the Spring Framework and Java 11. Does there exist a mechanism to perform several async tasks (like @Async spring)?
But with cancelation of all tasks on timeout without killing/interrupting threads? I mean something like go-routine context cancelation in go?
Solution
I highly recommend you read about: ExecutorService, ScheduledExecutorService and SimplAsyncTaskExecutor to understand the mechanism of task executor.
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ExecutorService.html
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html
It provide few built-in functions to execute the task asych with timeout and cancel policy...
You can refer the answer here how to execute schedule with timeout: https://stackoverflow.com/a/2759040/1439560
Answered By - Huy Nguyen
Answer Checked By - Clifford M. (JavaFixing Volunteer)