简体   繁体   English

ThreadPoolExecutor中没有任务,ThreadPoolexecutor会死吗?

[英]No Task in ThreadPoolExecutor , will the ThreadPoolexecutor die?

I have created the static object for ThreadPoolExecutor class and in my web application I'm adding tasks to ThreadPoolExecutor for every request. 我已经为ThreadPoolExecutor类创建了静态对象,并且在我的Web应用程序中,我为每个请求将任务添加到ThreadPoolExecutor中。

My question is after all the requests are processed and what happen to ThreadPoolExecutor class(in my case I have created the static object for thread poolexecutor) whether It becomes shut down the service or still waiting for new tasks to submit? 我的问题是,在处理完所有请求之后,ThreadPoolExecutor类(在我的情况下,我已为线程poolexecutor创建了静态对象)会发生什么事情,它是关闭服务还是仍在等待新任务提交?

If you don't shut it down with executor.shutdown() it'll stay running of course, waiting for tasks that may never come. 如果不使用executor.shutdown()将其关闭,则它当然会继续运行,等待可能永远不会发生的任务。

I'm sure this is described in the Javadocs for the class, but for some reason reading the Javadocs seems to be uncool these days. 我确定这在Javadocs中对该类进行了描述,但是由于某种原因,如今阅读Javadocs似乎很不爽。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM