Downloading a large set for files in Android in Parallel

59 sec read

Dear Developers

Our old friend Asynctask is very good in performing a task in background. Just override doInBackground and toss the work to background thread and keep you UI Thread free for performing other tasks , animation or responding to user clicks n touches.

Developer around the world develop asynctask class for different dedicated purposes like communicating with network or wrting to Filesystem or reading from Database etc.


all the asynctasks in your application takes the work from single messaging queue available. All this is performed sequentially. This means that if one asynctask takes some time to process its work so all other asynctask will wait.

So automatically overall performance and user experience for our app will degrade. It would have been good if these tasks can be performed in parallel fashion. Their will be multiple threads working to download files from internet in parallel fashion. Besides that there will a manager that manages the whole download by delegating the task to available threads.

Have a look a below diagram


As above diagram demonstrates , Download manager will take available thread from the threadpool. Delegate the task of downloading file to a thread. In Parallel fashion if Download manager further gets request to download another file from internet and delegate this task to another thread from pool.

Majic is unlike aysnctask different thread execute in parallel fashion not impacting performance on other thread by much.

How this all will be implement in Android will be discussed in Next Post.


Happy Coding !.

Note : Dear Copy-Paste Community :).
Hope you are doing good.
If you are a software engineer study the material before copy pasting.

Else knowledge gets increased when it is shared.

Leave a Reply

Your email address will not be published. Required fields are marked *