如何从类中返回一个对象实现Callable

时间:2015-05-23 13:22:41

标签: java multithreading callable countdownlatch completable-future

我有一个实现callable的类,我希望可调用类只返回一个Mat类型的对象。我将Future列表声明如下:

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

但我收到Cannot instantiate the type Future<List<Mat>>

请让我知道我做错了什么?

代码

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
    }

}

0 个答案:

没有答案