I use a extern api (ESRI API for Android) where I have a loop for which me return a class Future
...
for (Layer layer : layers) {
// ListenableFuture extends Future<V>
final ListenableFuture<FeatureQueryResult> future= gdbFeatureTable.queryFeaturesAsync(query);
future.addDoneListener(() -> {
try {
FeatureQueryResult result = future.get();
...
}
OR
try {
FeatureQueryResult result = future.get();
}
...
Is it possible to launch all queryFeaturesAsync and obtain the global result (result1 + result2 + etc..) with asynchronously after the loop for ? What's the best way ? promises? ThreadPoolExecutor ?
Thanks for your help
I think method
queryFeaturesAsync()
inside already usesThreadPoolService
, and usingThreadPoolService
to retreive result from anotherThreadPoolService
is overkill, IMHO.I would recomend you to use
AsyncTask
becuse it is native Android SDK tool and very simple to use:I made
AsyncTask
as an anonymous class for shortening of example. On production it must be static class.