0

I have a class that implements callable, and i want the callable class to return only one object of type Mat. I declared the Future list as follows:

    private static Future<List<Mat>> fiConspFutureList = null;
    fiConspFutureList = new Future<List<Mat>>();//Cannot instantiate the type Future<List<Mat>>

but i receive Cannot instantiate the type Future<List<Mat>>

please let me know what i am doing wrong?

Code:

static class FIConspMap implements Callable<Mat> {

    private Mat fiOnOffMap = null;
    private Mat fiOffOnMap = null;
    private ConspicuityMap fiConspMap = null;

    public FIConspMap() throws InterruptedException, ExecutionException {
        // TODO Auto-generated constructor stub
        this.fiOnOffMap = fiCompFutureList.get(0).get().get(0);
        this.fiOffOnMap = fiCompFutureList.get(0).get().get(1);
        this.fiConspMap = new ConspicuityMap(this.fiOnOffMap, this.fiOffOnMap, SysConsts.FI_TOKEN);
    }

    public Mat call() throws Exception {
        // TODO Auto-generated method stub
        return fiConspMap.getConspicuityMap();// here i want to return only an object of type Mat
    }

}
Amrmsmb
  • 1
  • 27
  • 104
  • 226
  • 1
    `Future` cannot be instantiated because it is an interface, not a class. You have have to use a class that *implements* this interface. Java provides a few (from the docs: ForkJoinTask, FutureTask, RecursiveAction, RecursiveTask, SwingWorker), but you can also code yours, depending on your need (which is not so clear at this point). – Eric Leibenguth May 23 '15 at 13:33
  • 1
    Why do you need to instantiate a Future? I suggest you look at CompletableFuture instead. – Ruben May 30 '15 at 15:40

0 Answers0