title: Spring Controller start processing after response is sent
body: <p>I am using a Spring MVC controller and want to start the execution of a task in a new thread. However the task should not start immediately but only after the response has been sent to the client. </p>
  
  <p>The sequence - in strict temporal order:</p>
  
  <ol>
  <li>request </li>
  <li>return new <code>ResponseEntity ...</code> / client receives HTTP status 200 OK.</li>
  <li>processing of the task begins.</li>
  </ol>
  
  <p>How do I achieve this? </p>
  
  <p>I wanted to use Spring's async abstraction by calling a method annotated with @Async, but it does not guarantee that the new thread waits for the response to be sent first.</p>