title: Stop Spring Boot on thread error
body: <p>I have this configuration using Spring Boot:</p>
  
  <pre><code>@Bean
  public TaskExecutor a() {
    return new SimpleAsyncTaskExecutor();
  }
  
  @Bean
  public CommandLineRunner b() {
    return (String... args) -&gt; {
      RunnableTask task = SomeRunnableTask();
      a().execute(task);
    };
  }
  </code></pre>
  
  <p>When that thread stops (for any reason) I want to shut down the Spring Boot application.</p>
  
  <p>The thread is a long running process connecting to a database, webservice, socket... So it's quite likely that at some point it'll fail.</p>
  
  <p>What's the right way of shutting down Spring Boot when a thread stops? Should I not be using <code>SimpleAsyncTaskExecutor</code> from Spring?</p>
  
  <p>Thanks!</p>