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,用于啟動一個核心線程
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用于啟動所有的核心線程
小結(jié)
ThreadPoolExecutor提供了prestartCoreThread方法,用于啟動一個核心線程,提供了prestartAllCoreThreads方法用于啟動所有的核心線程。
以上就是java線程池prestartCoreThread prestartAllCoreThreads的預(yù)熱源碼解讀的詳細(xì)內(nèi)容,更多關(guān)于java線程池預(yù)熱的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Java服務(wù)如何調(diào)用系統(tǒng)指令、Bat腳本記錄
這篇文章主要介紹了Java服務(wù)如何調(diào)用系統(tǒng)指令、Bat腳本記錄,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-06-06SpringBoot超詳細(xì)講解多數(shù)據(jù)源集成
今天分享下SpringBoot多數(shù)據(jù)源集成,我怕麻煩,這里我覺得我的集成也應(yīng)該是最簡單的,清晰明了2022-05-05idea啟動多個SpringBoot服務(wù)實例的最優(yōu)解決方法
啟動SpringBoot項目其實就是啟動Tomcat等服務(wù)容器,只要這個端口不同就能啟動多個服務(wù)實例了,本文主要介紹了idea啟動多個SpringBoot服務(wù)實例的最優(yōu)解決方法,感興趣的可以了解一下2024-05-05Java?map和bean互轉(zhuǎn)常用的方法總結(jié)
這篇文章主要給大家介紹了關(guān)于Java中map和bean互轉(zhuǎn)常用方法的相關(guān)資料,平時日常Java開發(fā),經(jīng)常會涉及到Java?Bean和Map之間的類型轉(zhuǎn)換,需要的朋友可以參考下2023-09-09Java實現(xiàn)儲存對象并按對象某屬性排序的幾種方法示例
這篇文章主要介紹了Java實現(xiàn)儲存對象并按對象某屬性排序的幾種方法,結(jié)合實例形式詳細(xì)分析了Java儲存對象并按對象某屬性排序的具體實現(xiàn)方法與操作注意事項,需要的朋友可以參考下2020-05-05