java线程池ExecutorService,里面有多少空余线程,怎么看
1个回答
展开全部
ExecutorService是个接口,如果你是用Executors静态方法生产的实例,见具体实现。
比如:
Java代码
public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) {
return new ThreadPoolExecutor(nThreads, nThreads,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(),
threadFactory);
}
那它是ThreadPoolExecutor的实例,你可以看它的方法,如getActiveCount(),getPoolSize()等。
比如:
Java代码
public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) {
return new ThreadPoolExecutor(nThreads, nThreads,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(),
threadFactory);
}
那它是ThreadPoolExecutor的实例,你可以看它的方法,如getActiveCount(),getPoolSize()等。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询