I need to execute a number of AsyncTask
s and then gather all their results, consolidate and then return the final result to my user.
I am looking at a way to manage multiple AsyncTask
s in Android. I am thinking of using a ExecutorService
from the Java Concurrency package but I stuck because ExecutorService
takes either Runnables or Callables ONLY. To establish my requirement I can use the
ExecutorService.invokeAll((Collection<? extends Callable<T>> tasks)
The invokeAll()
method will return a list of List<Future><V>>
only when all submitted tasks are completed and I can get my results for each task from its corresponding Future
.
All is well with ExecutorService
expect for the fact that it doesn't accept AsyncTask
.
Is there any other way to use AsyncTask
and ExecutorService
or if you can please recommend a different approach.