0

Unlike ExecutorService with awaitTermination(), dispose() in Scheduler in Reactor just invokes shutdownNow() when disposing; so how to shutdown Scheduler gracefully?

Sometimes we want to terminate our executorService with all submitted tasks completed:

// in java
executorService.shutdown();
int  retry =3; 
while(executorService.isTerminated() && retry-- >0){
    executorService.awaitTermination(3, TimieUnit.SECONDS);
}
if(!executorService.isTerminated()){
    executorService.shutdownNow();
}

As a rookie in Reactor, the only way for me to shutdown scheduler is invoking Scheduler.dispose(). But it seems that implements for Scheduler, such as Scheduler.BoundedElasticScheduler, just invokes executor.shutdownNow() to interrupt the inner workers, and ignore the state of submitted tasks. How can I gracefully shutdown the Scheduler until all the tasks complete?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Player.C
  • 1
  • 1
  • What exactly is the problem you have with `dispose()`? What are you trying to do or what is the issue? Please [edit] your question to include the source code you have as a [mcve], which shows the problem you have and how/when you want to shutdown the schedulers you are using. – Progman Aug 21 '21 at 10:16
  • thanks,question has been replenished just now @Progman – Player.C Aug 22 '21 at 06:30

0 Answers0