java - 分配给 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)
解决方案
推荐阅读
- c# - 当 TransferMode == Automatic 时定义 ASCII 传输的 WinSCP .NET 程序集自定义列表
- python - 检测数据框的所有更改
- windows - 在 opencv 中,有没有办法打开实时记录和创建的 .avi?
- javascript - 用手风琴连接 svg rect
- eclipse - 0000004a SSLHandshakeE E SSLC0008E: 无法初始化 SSL 连接
- angular - NG2339:“对象”类型上不存在属性
- java - 使用测试容器播种 mysql 数据库
- elasticsearch - Grafana 未从本地 Elastic Search 加载数据
- swift - 为什么似乎返回打印的函数声明为 Void?
- html - 我无法在此引号滑块上显示文本