Thursday, February 16, 2017

AsyncTask & multithreading

Android runs all async tasks in a single thread, which means, if one task is blocking, the other task will need to wait till it finishes.
In some cases you will need you async tasks to run simultaneously.
In such a case use:
AsyncTask.THREAD_POOL_EXECUTOR

Here is an example:
new SomeAsyncTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);