如何监控线程池的状态
发布时间:2022-09-09 15:28:21
发布人:syq

可以使用ThreadPoolExecutor以下方法:
getTaskCount() Returns the approximate total number of tasks that have ever been scheduled for execution.
getCompletedTaskCount() Returns the approximate total number of tasks that have completed execution. 返回结果少于getTaskCount()。
getLargestPoolSize() Returns the largest number of threads that have ever simultaneously been in the pool. 返回结果小于等于maximumPoolSize
getPoolSize() Returns the current number of threads in the pool
getActiveCount() Returns the approximate number of threads that are actively executing tasks