Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 18.104.22.168 release ready!
Owner and Founder. Opencart
The thread is a process which executes the sequence of instruction. In Android, if there is some task taking more than 5sec it will cause ANR (Application Not Responding) error. To avoid these cases we need to create a separate thread. In Android, there is UI thread which performs entire UI operation that’s mean we cannot perform any UI update on the background thread.
Android introduce Asynctask for such cases we can update UI component in Asynctask and perform the long-running operation at the same time. In Asynctask there are 3 methods onPreExecute(), onBackground() and onPostExecute(). We can perform UI component related operation on onPostExecute() method.
There is no specific limit to create a thread in android we can create as many threads we need to perform background operations. But creating too many threads can cause deadlock if we are unable to manage them. Thread pool is a better approach instead of creating separate threads.
Let’s now discuss when we have to create a Thread, Asynctask, and ThreadPool in android to perform background task. In Android, there are many options to execute background operations.
I hope you have got some idea where to use Threads, AsynckTask and ThreadPool.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.