我尝试将静态变量分配为ThreadPoolExecutor的参数。
Public class MyClass{
private static final int corePoolSize;
static{
corePoolSize= 30;
}
private static ExecutorService executorService = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue,threadFactory)
...
}
以上行失败。
如果我直接将值传递给threadpollexecutor,则下面没有问题
private static ExecutorService executorService = new ThreadPoolExecutor(30, maximumPoolSize, keepAliveTime, unit, workQueue,threadFactory)