IntelliJ无法解析符号"newFixedThreadPool"

Iri*_*dul 7 java intellij-idea cannot-find-symbol

我是IntelliJ和Java的新手.我正在尝试学习多线程,我遇到了Executors课程.

所以我想测试一下,这是我的代码示例.

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class LegController {
    private List<Runnable> legs;
    private ExecutorService execute;

    public LegController() {
        legs = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            legs.add(LegFactory.getLeg("LEFT"));
        }

        execute = new Executors.newFixedThreadPool(6);
    }

    public void start(){

        //TODO
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我收到一个错误:"无法解析符号'newFixedThreadPool'".我尝试了"无效缓存并重新启动",但它没有帮助,我尝试了同步和重建项目,但它也没有用.

我不明白这个问题的来源,因为导入了类Executors.此外,还有自动完成Executors的静态方法.也许输入有问题,但如果是这样,我该怎么办呢?

Jes*_*per 19

删除new此行中的关键字:

execute = new Executors.newFixedThreadPool(6);
Run Code Online (Sandbox Code Playgroud)

它应该是:

execute = Executors.newFixedThreadPool(6);
Run Code Online (Sandbox Code Playgroud)

该方法newFixedThreadPool是一种静态的类方法Executors.