5
在我們的應用程序中,我們有很多ThreadPoolExecutor
s。當應用程序空閒時,ThreadPoolExecutor
也是空閒的,但應用程序中空閒線程的數量非常高。在ThreadPoolExecutor中設置allowCoreThreadTimeOut()是否是一個好習慣?
在線程轉儲中,我發現大多數線程都屬於ThreadPoolExecutor
等待任務。保持這些工作線程活着有沒有副作用?我是否應該在ThreadPoolExecutor
中使用setAllowCoreThreadTimeOut()
,以便工作線程在空閒一段時間後死亡?