单独的线程VS服务+单独的线程 [英] SEPARATE THREAD VS SERVICE + SEPARATE THREAD

查看:171
本文介绍了单独的线程VS服务+单独的线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚看到谷歌I / O 2010 - 它被说Android的REST客户端应用程序:
 开始长从服务运行的操作
而且按照我的理解(我的英语很差)
 这样做的主要目的是prevent由系统杀死的应用程序。对?
它是很好的做法,从服务不仅网络的人执行所有长期运行操作?

just saw Google I/O 2010 - Android REST client applications where it was said: start long running operations from a Service And as I understand (My English is poor) the main purpose of this is to prevent the app to be killed by the system. Right? Is it good practice to perform all long running operation not only web ones from a Service?

据我了解,如果我创建活动的一个对象,然后应用程序会被杀死,我会失去这个对象,但如果我在服务和后处理创建这个对象会被杀死 - 我的对象仍然活着。对?

As I understand if I create an object in activity and then the app process will be killed I will lose this object, but if I create this object in a service and after process will be killed - my object still will be alive. Right?

(单独的线程)VS(SERVICE +单独的线程)

什么是我的问题的背景下有什么不同?

What is different in the context of my question?

推荐答案

1。在Android上的服务API是应用程序做的工作在后台的关键机制之一。

但是,它可以用一个简单的螺纹很容易实现。

But it can easily implemented using a simple thread.

但是:
*的一旦应用程序不再可见它通常被认为是消耗性的用户和候选由系统杀死如果它需要在别处存储器。主要的应用方式解决,这是通过启动服务组件,其中明确告知,他们正在做一些有价值的工作,将preFER,如果不真正需要系统无法杀死进程的系统。 *

因此​​,正如我理解是一个普通线程,为我们的情况下,服务之间的区别。

So as I understand that is difference between a regular thread and a Service for our case.

这篇关于单独的线程VS服务+单独的线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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