服务,异步任务与放大器之间的差异;线? [英] Difference between Service, Async Task & Thread?

查看:146
本文介绍了服务,异步任务与放大器之间的差异;线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是服务,异步任务和放大器之间的差异;线。如果我没看错的所有的人都用来做一些东西在后台。那么,如何决定使用哪是什么时候?

What is the difference between Service, Async Task & Thread. If i am not wrong all of them are used to do some stuff in background. So, how to decide which to use and when?

推荐答案

也许你已经读过有关它们的文档说明,我就不再赘述了,相反,我会尽量给复用我自己的话,希望他们能帮忙你。

Probably you already read the documentation description about them, I won't repeat them, instead I will try to give answer with my own words, hope they will help you.

  • 服务就像是一个活动,但没有接口。也许,如果你想获取比如你不会为它创建一个空活动的天气,为此,你将使用一个服务。

  • Service is like an Activity but has no interface. Probably if you want to fetch the weather for example you won't create a blank activity for it, for this you will use a Service.

一个主题是主题,也许你已经从另一部分知道这一点。你要知道,你不能从一个线程更新UI。您需要使用一个处理程序这一点,但进一步阅读。

A Thread is a Thread, probably you already know it from other part. You need to know that you cannot update UI from a Thread. You need to use a Handler for this, but read further.

这是AsyncTask的是建议要使用的智能线程。智能,因为它可以帮助它的方法,并且有两个是UI线程,这是很好的更新UI组件上运行的方法。

An AsyncTask is an intelligent Thread that is advised to be used. Intelligent as it can help with it's methods, and there are two methods that run on UI thread, which is good to update UI components.

我使用的服务,AsyncTasks频繁。螺纹少,或根本没有,因为我几乎可以做一切与AsyncTask的。

I am using Services, AsyncTasks frequently. Thread less, or not at all, as I can do almost everything with AsyncTask.

这篇关于服务,异步任务与放大器之间的差异;线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆