最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

java線程池prestartCoreThread prestartAllCoreThreads的預(yù)熱源碼解讀

 更新時(shí)間:2023年10月24日 09:30:08   作者:codecraft  
這篇文章主要介紹了java線程池prestartCoreThread prestartAllCoreThreads的預(yù)熱源碼解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

本文主要研究一下線程池的預(yù)熱

prestartCoreThread

java/util/concurrent/ThreadPoolExecutor.java

/**
     * Starts a core thread, causing it to idly wait for work. This
     * overrides the default policy of starting core threads only when
     * new tasks are executed. This method will return {@code false}
     * if all core threads have already been started.
     *
     * @return {@code true} if a thread was started
     */
    public boolean prestartCoreThread() {
        return workerCountOf(ctl.get()) < corePoolSize &&
            addWorker(null, true);
    }
ThreadPoolExecutor定義了prestartCoreThread,用于啟動(dòng)一個(gè)核心線程

prestartAllCoreThreads

java/util/concurrent/ThreadPoolExecutor.java

/**
     * Starts all core threads, causing them to idly wait for work. This
     * overrides the default policy of starting core threads only when
     * new tasks are executed.
     *
     * @return the number of threads started
     */
    public int prestartAllCoreThreads() {
        int n = 0;
        while (addWorker(null, true))
            ++n;
        return n;
    }
prestartAllCoreThreads用于啟動(dòng)所有的核心線程

小結(jié)

ThreadPoolExecutor提供了prestartCoreThread方法,用于啟動(dòng)一個(gè)核心線程,提供了prestartAllCoreThreads方法用于啟動(dòng)所有的核心線程。

以上就是java線程池prestartCoreThread prestartAllCoreThreads的預(yù)熱源碼解讀的詳細(xì)內(nèi)容,更多關(guān)于java線程池預(yù)熱的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Java中Arrays數(shù)組工具類的基本使用詳解

    Java中Arrays數(shù)組工具類的基本使用詳解

    Arrays類中的方法都是static修飾的靜態(tài)方法,在使用的時(shí)候可以直接使用類名進(jìn)行調(diào)用,而"不用"使用對(duì)象來調(diào)用(注意:是"不用"?而不是?"不能"),這篇文章主要給大家介紹了關(guān)于Java中Arrays數(shù)組工具類的基本使用,需要的朋友可以參考下
    2021-12-12
  • 淺談Java并發(fā)中的內(nèi)存模型

    淺談Java并發(fā)中的內(nèi)存模型

    這篇文章主要介紹了Java并發(fā)中的內(nèi)存模型,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-05-05
  • 最新評(píng)論

    宁陵县| 禄丰县| 江山市| 西城区| 中方县| 兴山县| 唐山市| 临泉县| 永济市| 奈曼旗| 湟源县| 合川市| 松江区| 湘西| 班戈县| 黄冈市| 涟水县| 体育| 陆良县| 留坝县| 丘北县| 安义县| 介休市| 迭部县| 无棣县| 财经| 沾化县| 板桥市| 京山县| 墨玉县| 潜山县| 谢通门县| 吉安市| 定日县| 同江市| 泸州市| 探索| 庐江县| 凭祥市| 沿河| 兴城市|