【发布时间】:2019-12-21 14:15:35
【问题描述】:
据我所知,未捕获的线程将终止于当前线程。 在下面的代码中,main方法已经执行了,但是为什么没有终止呢?
public static void main(String[] args) {
ExecutorService executorService = Executors.newFixedThreadPool(2);
executorService.execute(() -> {
while (true) {
throw new RuntimeException();
}
});
}
【问题讨论】:
-
所以你运行这个程序并且它永远不会停止运行?
-
@SamOrozco 是的,你可以练习一下。
标签: java threadpool main executorservice