java - How to add returned values from a Supplier to a FutureList -
i want run 3 methods posted below using completablefuture asynchronous supplier that, when executor finishes futurelist should contain 3 values returned 3 methods respectively. know how use futurelist, example:
futurelist = completablefuture.supplyasync() but in case, want like:
futurelist.add(completablefuture.supplyasync()) please let me know how can that.
methods:
this.compstabilitymeasure(this.frameijlist, this.frameiklist, sysconsts.stability_measure_token); this.settrackingrepvalue(this.comptrackingrep(this.frameijlist, this.frameiklist, sysconsts.tracking_repeatability_token)); this.setviewpntrepvalue(this.compviewpntrep(this.frameijlist, this.frameiklist, sysconsts.viewpoint_repeatability_token)); compstabilitymeasure method implementation:
private void compstabilitymeasure(arraylist<mat> frameijlist, arraylist<mat> frameiklist, string token) throws interruptedexception, executionexception { // todo auto-generated method stub synchronized (frameijlist) { synchronized (frameijlist) { this.setrepvalue(this.comprep(frameijlist, frameiklist, token)); this.setsymrepvalue(this.compsymrep(this.getrepvalue(), frameiklist, frameijlist, token)); } } }
you want @ using "thencombineasync", eg:
completablefuture<string> firstfuture = firstmethod(); completablefuture<string> secondfuture = secondmethod(); completablefuture<string> thirdfuture = thirdmethod(); completablefuture<list<string>> allcompleted = firstfuture .thencombineasync(secondfuture, (first, second) -> listof(first, second)) .thencombineasync(thirdfuture, (list, third) -> { list.add(third); return list; });
Comments
Post a Comment