Handler和其他与android线程相关的术语

Handler和其他与android线程相关的术语

本文介绍了什么是looper,Handler和其他与android线程相关的术语?这些类之间有什么关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到有关android中计时器,异步任务,处理程序,循环程序等线程的详细说明?

Where can I find detailed explanation of threads like timer, async task, handler, looper etc in android?

推荐答案

在这里:

线程在后台线程中计划任务以供将来执行的工具.可以将任务安排为一次性执行,也可以安排为定期执行重复执行.

A facility for threads to schedule tasks for future execution in a background thread. Tasks may be scheduled for one-time execution, or for repeated execution at regular intervals.

与每个Timer对象相对应的是一个后台线程,该线程用于依次执行所有计时器的任务.

Corresponding to each Timer object is a single background thread that is used to execute all of the timer's tasks, sequentially.

有关更多信息,请在此处.

AsyncTask允许正确且轻松地使用UI线程.此类允许您执行后台操作并在UI线程上发布结果,而无需操纵线程和/或处理程序.

AsyncTask enables proper and easy use of the UI thread. This class allows you to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

AsyncTask被设计为围绕Thread和Handler的帮助器类,并且不构成通用的线程框架.

AsyncTask is designed to be a helper class around Thread and Handler and does not constitute a generic threading framework.

有关更多信息,请在此处.

处理程序使您可以发送和处理与线程的MessageQueue关联的Message和Runnable对象.每个Handler实例都与一个线程和该线程的消息队列关联.

A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message queue.

创建新的Handler时,它将绑定到正在创建它的线程的线程/消息队列中-从那时起,它将把消息和可运行对象传递到该消息队列并在它们出来时执行它们消息队列.

When you create a new Handler, it is bound to the thread / message queue of the thread that is creating it -- from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue.

有关更多信息,请在此处.

用于运行线程的消息循环的类.默认情况下,线程没有与之关联的消息循环;要创建一个,请在运行循环的线程中调用prepare(),然后使用loop()使其处理消息,直到循环停止为止.

Class used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, call prepare() in the thread that is to run the loop, and then loop() to have it process messages until the loop is stopped.

有关更多信息,请此处.

这篇关于什么是looper,Handler和其他与android线程相关的术语?这些类之间有什么关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 22:32