Reputation: 201
Is there a way to dig into an ExecutorServer
object to see how many threads are currently being used?
Upvotes: 1
Views: 112
Reputation: 597114
if (executor instanceof ThreadPoolExecutor) {
int poolSize = ((ThreadPoolExecutor) executor).getPoolSize();
// or
int currentlyActive = ((ThreadPoolExecutor) executor).getActiveCount();
}
But generally, you should know that, because you have constructed the service (unless it is hidden in some bad API)
Upvotes: 2