Recent Posts

Site Creator

By

By

By

Downloading a large set for files in Android in Parallel

Posted on

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.

asy.001

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

threadpoolimg.001

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.

Thanks

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.







Disclaimer: The aforesaid writeup by Relsell Global writer is for the general understanding of the readers. It does not render any professional advice or opinion.

SHARE THIS PAGE!

Leave a Reply

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