开发者社区 问答 正文

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

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

展开
收起
Medusa 2021-10-19 19:12:07 1732 分享 版权
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 展开评论