开发者

Thread v/s Async task [duplicate]

开发者 https://www.devze.com 2023-02-24 12:20 出处:网络
This question already has answers here: Closed 10 years ago. P开发者_开发问答ossible Duplicate: Difference between Service, Async Task & Thread?
This question already has answers here: Closed 10 years ago.

P开发者_开发问答ossible Duplicate:

Difference between Service, Async Task & Thread?

I am downloading around 600 images. I want this task to run in background, which method is the best method for it. Async or thread? Can anyone please tell me?


Do you plan on post processing after downloading the images? If you create a background thread and your main thread exits before the background threads are complete, then the threads will be aborted IN MOST Programming languages. It shouldnt really matter what method you choose if you create a barrier to prevent your programming from exiting until all your images are downloaded. I would run background threads off a threadpool.


AsyncTask. Just use it and you'll see why it better than threading... Threading just introduces another layer of complexity. The goal is to reduce complexity.

ETA: If possible, include as many as possible with the APK... 600 images is a ton for poor 3G and his/her merry dial-up like speeds.


Here is an article comparing various task execution mechanisms in Android.

0

精彩评论

暂无评论...
验证码 换一张
取 消