处理器VS主题

编程入门 行业动态 更新时间:2024-10-10 03:25:42
本文介绍了处理器VS主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道,一劳永逸。我读过很多地方。当我想要做一些很长一段时间的操作,我应该使用处理程序。

I would like to know, once for all. I've read in many places. When I want do some 'long time operations' I should use a Handler.

但我不知道为什么?我所有的长时操作我周围有一个普通的线程,并能正常工作。

But I don't get why? All my 'long-time-operations' I surround with a regular threads, and it works fine.

我为什么要使用处理程序此?

唯一一次我不得不用处理程序是,当我不得不安排一些任务( postDelayed )

The only time I had to use Handler was, when I had to schedule some task(postDelayed)

有什么主要的想法我想念处理(当我真的应该使用它)?或者,也许确实没有区别?

Is there any main idea I miss about handlers(When I should really use it)? Or maybe there isn't really difference?

推荐答案

一个处理器让你从你的后台线程UI线程进行通信了。这是因为,UI操作是由后台线程内禁止的。需要注意的是,在开始的1.5版,该 AsyncTask的类使得它更容易做到这一点。

A Handler lets you communicate back with the UI thread from your background thread. This is because UI operations are forbidden from within background threads. Note that starting at version 1.5, the AsyncTask class makes it much easier to do so.

更多推荐

处理器VS主题

本文发布于:2023-11-27 21:40:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639698.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:处理器   主题

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!