title: Spring mvc concurrent request processing
body: <p>Can anyone tell how I can process http requests concurrently by Spring mvc?
  I've tried to use CompletableFuture or DeferredResult for that, it allows me to process a request in another thread, but next request is still waiting until previous is finished.</p>
  
  <p>What might I miss?</p>
  
  <p>Methods of a controller:</p>
  
  <pre><code>@RequestMapping(value = "simple/async/cf", method = RequestMethod.GET)
  public CompletableFuture&lt;ResponseEntity&lt;String&gt;&gt; simpleAsyncCf() {
      return CompletableFuture.runAsync(() -&gt; sleep(1000))
              .thenApplyAsync(v -&gt; ResponseEntity.ok(getRandomString()));
  }
  
  
  @RequestMapping(value = "simple/async/df", method = RequestMethod.GET)
  public DeferredResult&lt;ResponseEntity&lt;String&gt;&gt; simpleAsyncDf() {
      DeferredResult&lt;ResponseEntity&lt;String&gt;&gt; result = new DeferredResult&lt;&gt;();
      CompletableFuture.runAsync(() -&gt; sleep(1000))
              .thenApplyAsync(v -&gt; result.setResult(ResponseEntity.ok(getRandomString())));
      return result;
  }
  </code></pre>