分配给ThreadPoolExecutor的静态变量

时间:2019-04-02 05:42:29

标签: java variables static threadpoolexecutor

我尝试将静态变量分配为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)

0 个答案:

没有答案