Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>SimpleAsyncTaskExecutor</code> has no meaningful state, it does not require shutting down gracefully. Also, I'm not sure what you mean by "the thread runs the entire life of the web application" - which thread are you referring to? </p> <p>However, the threads that it spawns may be preventing your server from shutting down. <code>SimpleAsyncTaskExecutor</code> uses a <code>ThreadFactory</code> to create its threads, and by default threads that are created are not daemon threads, and so any spawned threads which are still executing when the shutdown is initiated will continue, and the server will only terminate when all of those spawned threads are finished.</p> <p>As a solution, I suggest using a <code>ThreadPoolTaskExecutor</code> in preference to the <code>SimpleAsyncTaskExecutor</code>. This has a boolean property which controls what happens when a shutdown occurs, and it can force the termination of the thread pool if required.</p> <p>If you still want to use <code>SimpleAsyncTaskExecutor</code>, then you could inject it with a custom <code>ThreadFactory</code> which creates deamon threads. This will allow the server to shutdown regardless of the state of those spawned threads. This might be dangerous, though, if those threads could leave resources in an unstable state.</p> <p>Spring provides a bean-friendly implementation of <code>ThreadFactory</code> (<code>CustomizableThreadFactory</code>) which you can inject into the <code>SimpleAsyncTaskExecutor</code>, setting the <code>daemon</code> property to <code>false</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload