2012-01-12 4 views

答えて

2
if (executor instanceof ThreadPoolExecutor) { 
    int poolSize = ((ThreadPoolExecutor) executor).getPoolSize(); 
    // or 
    int currentlyActive = ((ThreadPoolExecutor) executor).getActiveCount(); 
} 

しかし、一般的に、あなたは(それはいくつかの悪いAPIの中に隠されていない限り)

+0

それは(おそらくnewCachedThreadPoolにのみ有用です)あなたがサービスを構築しているので、知っている必要があります。 – Tudor

+0

パーフェクト、ありがとう。エグゼキュータは 'Executors.newFixedThreadPool(tpool)'を使って生成されましたが、私はそれがThreadPoolExecutorにキャストできることを一般に知らなかった。知っておいてよかった! – OddProblems

関連する問題