四種線程池類型

ExecutorService threadPool = Executors.newFixedThreadPool(5);
ExecutorService threadPool4 = Executors.newSingleThreadExecutor();
ExecutorService threadPool2 = Executors.newCachedThreadPool();
ExecutorService threadPool3 = Executors.newScheduledThreadPool(5);

前兩個大小有限,第一個線程maximumPoolSize爲5,第二個爲1,後兩個大小無限,newCachedThreadPool爲阻塞隊列,newScheduledThreadPool爲優先隊列

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章