简体   繁体   English

无法从RecursiveAction类调用coInvoke函数

[英]Cannot call coInvoke function from RecursiveAction class

I have written a simple code to run in parallel using the Java fork join functionality. 我已经编写了一个简单的代码,可以使用Java fork join功能并行运行。

I am using Java version 7 (JDK 1.7) 我正在使用Java版本7(JDK 1.7)

import java.util.concurrent.RecursiveAction;

public class forkedPotential extends RecursiveAction {

    public forkedPotential(double rmin,double rmax,double rstep){

        for (double rad = rmin; rad <= rmax; rad = rad + rstep){
           double V = rad*rad;
           System.out.println(rad+" "+V);
        }

    }

    @Override
    protected void compute() {
        forkedPotential first = new forkedPotential(0.01,1.0,0.1);
        forkedPotential second = new forkedPotential(1.01,2.0,0.1);
        forkedPotential third = new forkedPotential(2.01,3.0,0.1);
        forkedPotential fourth = new forkedPotential(3.01,4.0,0.1);
        forkedPotential fifth = new forkedPotential(4.01,5.0,0.1);
        coInvoke(new forkedPotential(0.01,1.0,0.1),new forkedPotential(1.01,2.0,0.1));
    }

}

I have a problem however that coInvoke cannot be called. 我有一个问题,但是无法调用coInvoke。

cannot find symbol
  symbol: method coInvoke(forkedPotential,forkedPotential)
  location: class forkedPotential
----

This should be an acceptable use as forkedPotential extends RecursiveAction. 这应该是可以接受的用法,因为forkedPotential扩展了RecursiveAction。 And Alt-Return does not give me any helpful guidance. 而且Alt-Return不会给我任何有用的指导。

I have tried other utilisations of coInvoke such as 我尝试了coInvoke的其他用途,例如

        forkedPotential[] tasks = {first,second,third,fourth,fifth};
        coInvoke(tasks);

but with no joy. 但没有喜悦。

I do not know why this coInvoke function cannot be found as is is a function in RecursiveAction. 我不知道为什么不能像在RecursiveAction中那样找到该coInvoke函数。

Any advice would be appreciated. 任何意见,将不胜感激。

Thank you very much. 非常感谢你。

I have fixed this issue by substituting 我已通过替代来解决此问题

        coInvoke(tasks);

With

        RecursiveAction.invokeAll(tasks);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM