I am trying to define an Async method using Spring that needs to be called at the end of a synchronous function, like below:
void syncFunction() {
...
asyncFuntion();
}
@Async
void asyncFunction() {
...
}
I need to add a delay of 10 seconds before the execution of asyncFunction
begins and would like to avoid adding Thread.sleep()
. I've also explored @Scheduled
annotation, but it doesn't seem to work for a one-time
scheduled task. What is the best way to achieve this using Spring? Thanks in advance.