我想知道,一劳永逸。我读过很多地方。当我想要做一些很长一段时间的操作,我应该使用处理程序。
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主题
发布评论