source: class AsyncService {
  
    @Async
    public CompletableFuture<List<String>> completableFutureTask(String start) {
      logger.warn(Thread.currentThread().getName() + "start this task!");
      // 找出所有以 F 开头的电影
      List<String> results =
          movies.stream().filter(movie -> movie.startsWith(start)).collect(Collectors.toList());
      // 模拟这是一个耗时的任务
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      // 返回一个已经用给定值完成的新的CompletableFuture。
      return CompletableFuture.completedFuture(results);
    }
  
    @Autowired AsyncService asyncService;
  
  }
  
  class AsyncServiceTest {
  
    @Autowired AsyncService asyncService;
  
    @Test
    public void testCompletableFutureTask() throws InterruptedException, ExecutionException {
  
target:     // 开始时间
      long start = System.currentTimeMillis();
      // 开始执行大量的异步任务
      List<String> words = Arrays.asList("F", "T", "S", "Z", "J", "C");
      List<CompletableFuture<List<String>>> completableFutureList =
          words.stream()
              .map(word -> asyncService.completableFutureTask(word))
              .collect(Collectors.toList());
      // CompletableFuture.join（）方法可以获取他们的结果并将结果连接起来
      List<List<String>> results =
          completableFutureList.stream().map(CompletableFuture::join).collect(Collectors.toList());
      // 打印结果以及运行程序运行花费时间
      System.out.println("Elapsed time: " + (System.currentTimeMillis() - start));
      System.out.println(results.toString());
    }
  
  }