开发者社区> 问答> 正文

线程池创建之后,会立即创建核心线程吗?

线程池创建之后,会立即创建核心线程吗?

展开
收起
Medusa 2021-10-19 19:12:07 1491 1
1 条回答
写回答
取消 提交回答
  • 不会。在刚刚创建ThreadPoolExecutor 的时候,线程并不会立即启动,而是要等到有任务提交时才会启动,除非调用了prestartCoreThread/prestartAllCoreThreads 事先启动核心线程。

    • prestartCoreThread:Starts a core thread, causing it to idly wait for work. This overrides the default policy of starting core threads only when new t asks are executed.
    • prestartAllCoreThreads:Starts all core threads.

    资料来源:《Java开发者面试百宝书》,链接:https://developer.aliyun.com/topic/download?id=7899

    2021-10-20 12:15:51
    赞同 1 展开评论 打赏
来源圈子
更多
收录在圈子:
阿里云开发者社区官方技术圈,用户产品功能发布、用户反馈收集等。
问答排行榜
最热
最新

相关电子书

更多
多IO线程优化版 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载