Thread base of Fundamental Android developer
Thread by The cheese Factory
I’m do this for make myself to only remember
Thread is very important in any mobile, No matter what Android & IOS
Because Mobile have been limited of resource
Limited CPU
Limited Battery
Only few of developers master Threading
You Have to master Threading if you want to be a mobile developer
Actually you have already had experience with Thread
- Loading data from server with Retrofit
- Loading image from server with Glide
- Reception = Main Thread -> work with one Application only.
- Teelek = Background Thread -> Work instant main thread.
When seperate job to a Background Thread
= 60 fps (16.67ms/1job)
Small job -> Run on Main thread
Expensive job -> Run on Background Thread
/**
* Thread Method 1: Thread (Not Use this thread)
**//**
* Thread Method 2 : Thread with Handler (Use This Solution
**//**
* Thread Method 3 : Handler Only (Work instand thread)
**//**
* Thread Method 4: HandlerThread (2 3 combined)
**//**
* Thread Method 5: Thread Method 5: AsyncTask
**//**
* Thread Method 6: AsyncTaskLoader
**/
AsyncTask
It can work just 1 time if it have multi asynctask , it’s work follow queue
How to run multi AsyncTask
sampleAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, 0, 100);
AsyncTask is made for “Very short Task” (< 5 seconds)
AsyncTask Concept
Short Operations Publish Result on the UI Thread.