日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android运行的线程中,android中线程是否运行在单独的进程中?

發布時間:2023/12/2 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android运行的线程中,android中线程是否运行在单独的进程中? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

android sdk中的描述

Caution:A

service runs in the main thread of its hosting process—the service

doesnotcreate

its own thread and

doesnotrun

in a separate process (unless you specify otherwise). This means

that, if your service is going to do any CPU intensive work or

blocking operations (such as MP3 playback or networking),

you should create a new thread

within the service to do that work. By using a

separate thread, you will reduce the risk of Application Not Responding

(ANR) errors and the application's main thread can remain dedicated

to user interaction with your activities.

service是運行在主線程上的,而不是運行在另一個線程中,如果你想在service中處理很占時間的操作,你必須在service中開線程,這樣可以降低activity沒有響應的風險。

Should you use a service or a thread?

A service is simply a component that can run in the background

even when the user is not interacting with your application. Thus,

you should create a service only if that is what you need.

If you need to perform work outside your main thread, but only

while the user is interacting with your application, then you

should probably instead create a new thread and not a service. For

example, if you want to play some music, but only while your

activity is running, you might create a thread inorProcesses

and Threadingdocument for more

information about threads.

Remember that if you do use a service, it still runs in your

application's main thread by default, so you should still create a

new thread within the service if it performs intensive or blocking

operations.

摘自:http://blog.csdn.net/cwx01perfect/article/details/7522816

總結

以上是生活随笔為你收集整理的android运行的线程中,android中线程是否运行在单独的进程中?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。