简体   繁体   English

Worker线程与后台线程android有什么区别?

[英]What is difference between Worker thread vs Background thread android?

任何人都可以简单地解释我们在哪里使用工作线程和后台线程以及一些实时示例。

这很简单:在Android“背景”和“工作者”线程是相同的。

Background thread as name states runs separate from main thread and does not hang the main thread so its a async operation and a Worker thread is runs parallel to main thread. 作为名称状态的后台线程与主线程分开运行,并且不挂起主线程,因此它的异步操作和工作线程与主线程并行运行。 In short we can run worker thread and background thread at the same time together. 简而言之,我们可以同时运行工作线程和后台线程。

Background threads are dead once the application exists whereas worker threads complete the action even if the application closed. 一旦应用程序存在,后台线程就会死亡,而即使应用程序关闭,工作线程也会完成操作。

They are synonyms. 他们是同义词。 You can check the android Worker threads reference where they remark that: 您可以检查android Worker线程参考他们注释的位置:

Because of the single threaded model described above, it's vital to the responsiveness of your application's UI that you do not block the UI thread. 由于上面描述的单线程模型,对于您不应阻止UI线程的应用程序UI的响应性至关重要。 If you have operations to perform that are not instantaneous, you should make sure to do them in separate threads ( "background" or "worker" threads ). 如果您要执行的操作不是即时的,则应确保在单独的线程( “后台”或“工作线程”线程 )中执行它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM