public class ThreadPoolUtils {
private int CPUCOUNT = Runtime.getRuntime().availableProcessors();
private ThreadPoolExecutor cpuExecutor = new ThreadPoolExecutor(CPUCOUNT, CPUCOUNT,
30, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>(), sThreadFactory);
private ThreadPoolExecutor iOExecutor = new ThreadPoolExecutor(64, 64,
30, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>(), sThreadFactory);
....
这段代码,我的理解是应该把 cpuExecutor iOExecutor,设置为static的。用的时候根据不同任务类型分别拿到cpuExecutor iOExecutor执行。
但是如果设置成静态就是我们工具类中有两种类型的threadPool,但是这两个都是都是我这个应用中的线程数呀:比如我用iOExecutor时,cpuExecutor中也有线程呀,这不也是一种浪费吗?所以,请问老师我的理解对不对?这中情况如何处理?