> For the complete documentation index, see [llms.txt](https://xiaoxiami.gitbook.io/java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xiaoxiami.gitbook.io/java/executorservice-xian-cheng-chi.md).

# ExecutorService 异步线程池

[线程池 ExecutorService 的使用例子](https://blog.csdn.net/xiaojin21cen/article/details/81810534)

[Java多线程-Callable的Future返回值的使用](https://www.cnblogs.com/syp172654682/p/9788051.html)

[ExecutorService](https://www.jianshu.com/p/ff42d9aad56c)

```java
@RestController
@RequestMapping("/hello")
public class HelloController {

	private ExecutorService service = Executors.newFixedThreadPool(10);

    @GetMapping
    public String hello() {
        service.execute(new Runnable() {
    
            @Override
            public void run() {
                try {
                    TimeUnit.SECONDS.sleep(3);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
    
                System.out.println("我醒了");
            }
        });
    
        return "hello world";
    }
}
```

实例理解:

会先返回"hello world", 3秒钟后控制台输出"我醒了"
