0

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?

greybeard
  • 2,249
  • 8
  • 30
  • 66

1 Answers1

0

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

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/task/SimpleAsyncTaskExecutor.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

Huy Nguyen
  • 1,931
  • 1
  • 11
  • 11