service浅解
来源:互联网 发布:程序员转行当老师 编辑:程序博客网 时间:2024/06/06 00:29
在项目中,我在service中作如下操作:
从数据库中读取数据,然后把读取到的数据写入了另一个数据库表的同时,还把它通过串口传往另一个终端。
运行时发现log中有如下提醒:
The application may be doing too much work on its main thread.
回头查看Android API,其中有对service如下解释:
Note that services, like other application objects, run in the main thread of their hosting process. This means that, if your service is going to do any CPU intensive (such as MP3 playback) or blocking (such as networking) operations, it should spawn its own thread in which to do that work.
Most confusion about the Service class actually revolves around what it is not:
- A Service is not a separate process. The Service object itself does not imply it is running in its own process; unless otherwise specified, it runs in the same process as the application it is part of.
- A Service is not a thread. It is not a means itself to do work off of the main thread (to avoid Application Not Responding errors).
0 0
- service浅解
- Service
- Service
- service
- Service
- service
- Service
- Service
- service
- Service
- Service
- Service
- service
- service
- Service
- Service
- Service
- Service
- JAVA设计模式之适配器模式
- 循环-27. 求给定序列前N项和之五(15)
- 最简单的wxPython的界面设计
- c++地址复制strcpy
- 代理模式
- service浅解
- Nutch开发者 网站发布
- 专家详解竞彩普及:合理分配资金玩转单场竞猜
- AndroidManifest.xml配置文件详解
- js 等比例缩放图片
- 设计模式--外观模式
- 外观模式
- 3.4、C++输入输出
- 求逆元的两种方法