Home > Back-end >  Multithreaded shutdown method
Multithreaded shutdown method

Time:10-06

In springboot project, using the ExecutorService utility class to create a thread pool object, then calls the execute method to perform a task in the cycle, cycle after the call the shutdown method, the whole process is roughly such, when the interface is the second request, will quote Java. Util. Concurrent. RejectedExecutionException errors, I summed up the problem is a shutdown method invocation, the needs of the business, if the volume is not can choose not to call shutdown method; The second question is the ExecutorService tools used when creating the thread pool objects (AbortPolicy) is the default refused to strategy, this strategy will discarding the new submission task in the task blocked,

CodePudding user response:

Optimal method: according to your own judgment end conditions
  • Related