What is the difference between AsyncTask and Thread/Runnable ?
What is the difference between AsyncTask and Thread/Runnable ?
The main differences between AsyncTask and Thread/Runnable in Android are:
Threading model: AsyncTask runs on a separate worker thread by default, while Thread/Runnable requires manual thread management[1][2][4].
UI interaction: AsyncTask allows publishing progress updates and delivering results to the UI thread, while Thread/Runnable requires manual UI thread access using methods like View.post(Runnable)
[1][4][5].
Lifecycle handling: AsyncTask handles configuration changes like screen rotations automatically, while Thread/Runnable requires manual lifecycle management[1][2].
Execution: AsyncTask can only be executed once, while Thread/Runnable can be reused[2][4].
Limitations: AsyncTask is designed for short-running tasks (a few seconds at most), while Thread/Runnable is suitable for longer-r...
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào