Won several active thread pool threads currently in use

scenes to be used:

 For multithreaded operations, in order to avoid OOM, you need to manually control the number of threads, then, need to get the number of threads currently active, control has been done

/将exes转换为ThreadPoolExecutor,ThreadPoolExecutor有方法 getActiveCount()可以得到当前活动线程数

   

eg:

   ExecutorService exes= Executors.newFixedThreadPool(10);

    int threadCount = ((ThreadPoolExecutor)exes).getActiveCount();

 

Guess you like

Origin www.cnblogs.com/lshan/p/11358961.html