現在使用中のいくつかのアクティブなスレッドプールのスレッドを受賞

使用シナリオ:

 マルチスレッド操作については、OOMを避けるために、手動でスレッド数を制御する必要がある、そして、現在アクティブなスレッドの数を取得する必要があり、制御が行われています

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

   

例えば:

   ExecutorService exes= Executors.newFixedThreadPool(10);

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

 

おすすめ

転載: www.cnblogs.com/lshan/p/11358961.html