java線程池prestartCoreThread prestartAllCoreThreads的預(yù)熱源碼解讀
序
本文主要研究一下線程池的預(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)文章
maven實(shí)現(xiàn)docker自動(dòng)化部署插件的使用
本文主要介紹了maven實(shí)現(xiàn)docker自動(dòng)化部署插件的使用,分享給大家,感興趣的小伙伴們可以參考一下2021-06-06Java服務(wù)如何調(diào)用系統(tǒng)指令、Bat腳本記錄
這篇文章主要介紹了Java服務(wù)如何調(diào)用系統(tǒng)指令、Bat腳本記錄,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-06-06SpringBoot超詳細(xì)講解多數(shù)據(jù)源集成
今天分享下SpringBoot多數(shù)據(jù)源集成,我怕麻煩,這里我覺(jué)得我的集成也應(yīng)該是最簡(jiǎn)單的,清晰明了2022-05-05idea啟動(dòng)多個(gè)SpringBoot服務(wù)實(shí)例的最優(yōu)解決方法
啟動(dòng)SpringBoot項(xiàng)目其實(shí)就是啟動(dòng)Tomcat等服務(wù)容器,只要這個(gè)端口不同就能啟動(dòng)多個(gè)服務(wù)實(shí)例了,本文主要介紹了idea啟動(dòng)多個(gè)SpringBoot服務(wù)實(shí)例的最優(yōu)解決方法,感興趣的可以了解一下2024-05-05Java?map和bean互轉(zhuǎn)常用的方法總結(jié)
這篇文章主要給大家介紹了關(guān)于Java中map和bean互轉(zhuǎn)常用方法的相關(guān)資料,平時(shí)日常Java開(kāi)發(fā),經(jīng)常會(huì)涉及到Java?Bean和Map之間的類型轉(zhuǎn)換,需要的朋友可以參考下2023-09-09Java實(shí)現(xiàn)儲(chǔ)存對(duì)象并按對(duì)象某屬性排序的幾種方法示例
這篇文章主要介紹了Java實(shí)現(xiàn)儲(chǔ)存對(duì)象并按對(duì)象某屬性排序的幾種方法,結(jié)合實(shí)例形式詳細(xì)分析了Java儲(chǔ)存對(duì)象并按對(duì)象某屬性排序的具體實(shí)現(xiàn)方法與操作注意事項(xiàng),需要的朋友可以參考下2020-05-05Java中使用回調(diào)函數(shù)的方法實(shí)例
本文主要介紹了Java中使用回調(diào)函數(shù)的方法實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05