1. 程式人生 > >26_線程池_內部實現_ThreadPoolExecutor

26_線程池_內部實現_ThreadPoolExecutor

single 不同的 ade news info AD 實現 內部實現 exec

【ThreadPoolExecutor簡述】

無論是Executors類的newFixedThreadPool()、newSingleThreadExecutor(),還是newCachedThreadPool()方法,雖然看起來創建的線程有著完全不同的特點,期內部實現均使用了ThreadPoolExecutor實現。

下面展示一下Executors類中對應的以上幾個靜態方法的源碼:

[ newFixedThreadPool()方法 ]

技術分享圖片

[ newSingleThreadExecutor()方法]

技術分享圖片

[ newCachedThreadPool()方法 ]

技術分享圖片

26_線程池_內部實現_ThreadPoolExecutor