AsyncTask的VS主题的机器人机器人、主题、AsyncTask、VS

由网友(日月难渡)分享简介:在UI我想要做一些,我使用单独的thread.But我建议的其他背景工作。对于这样做的asynctask.What是AsyncTask的与主题之间的主要区别,在这种情况下,我使用的线程和AsyncTask的? In UI I want to do some background work.For that i use...

在UI我想要做一些,我使用单独的thread.But我建议的其他背景工作。对于这样做的asynctask.What是AsyncTask的与主题之间的主要区别,在这种情况下,我使用的线程和AsyncTask的?

In UI I want to do some background work.For that i use separate thread.But i suggested by other do it in asynctask.What is the main difference between Asynctask and Thread,in which scenario i've to use Thread and Asynctask?.

推荐答案

对于长时间运行或CPU密集型任务,基本上有两种方法可以做到这一点:Java线程,和Android的原生的AsyncTask

For long-running or CPU-intensive tasks, there are basically two ways to do this: Java threads, and Android's native AsyncTask.

无论一个是一定比其他更好的,但知道何时使用的电话是必不可少的利用了系统的性能,以你的利益。

Neither one is necessarily better than the other, but knowing when to use each call is essential to leveraging the system's performance to your benefit.

使用的AsyncTask为:

在简单的网络操作不要求下载大量数据的 磁盘密集型任务,可能超过几毫秒采取更多

使用Java线程的:

涉及中度到大量数据(无论是上载或下载)网络操作 这需要在后台运行高CPU任务 要控制相对于GUI线程的CPU使用情况的任何任务 Network operations which involve moderate to large amounts of data (either uploading or downloading) High-CPU tasks which need to be run in the background Any task where you want to control the CPU usage relative to the GUI thread

和有很多很好的资源,通过互联网可以帮助你:

And there are lot of good resources over internet which may help you:

http://www.vogella.com/articles/AndroidBackgroundProcessing/article.html http://www.mergeconflict.net/2012/05/java-threads-vs-android-asynctask-which.html

阅读全文

相关推荐

最新文章