shutdown方法
1.线程池状态变为shutdown
2.不会接收新任务
3.已提交的任务会执行完
4.此方法不会阻塞调用线程执行
ExecutorService executorService = Executors.newFixedThreadPool(2);
executorService.submit(() -> {
log.debug("task1 running");
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
log.debug("task1 finished");
});
executorService.submit(() -> {
log.debug("task2 running");
try {
TimeUnit.SECONDS.sleep(1);
标签:shutdown,log,49,线程,关闭,debug,sleep,executorService
From: https://blog.csdn.net/qq_36352889/article/details/139511118