Android handle operating mechanism, generics, event distribution mechanism

Source: Internet
Author: User

Handle operating mechanism

Handler is to resolve the communication between threads and threads.

Handler's message processing consists of five components, message,Handler, messageQueue,Looper and ThreadLocal

Message: Messages passed between threads for exchanging data between thread

Handler: Send messages that are used primarily for sending and processing messages, typically with SendMessage (), except Sendmessageatfrontofqueue () are Sendmessageattime methods

Message Queue: Holds all messages sent through handler, this part of the message will remain in the message queue, waiting to be processed, each thread has only one messageque Ue

Looper: Every time a message is found in the messages queue, it is taken out and passed to the handler Handlemessage () method with only one Looper per thread

ThreadLocal: is a data storage class inside a thread that can store data in a specified thread, and after the data is stored, only in the specified thread can get to the data stored in the

Generic understanding

generics: allows the implementation of classes, interfaces when specifying the type parameters, improve the security of Java program Type, eliminate many of the source of the cast, the code is more readable, reduce the chance of error, use type parameter definition attribute private T class name;

Event distribution mechanism:

Event Distribution object: Click on the nature of the object event distribution: Pass the Click event to a specific ViewWhat objects are passed between the & process events? Activity, ViewGroup, View

Android handle operating mechanism, generics, event distribution mechanism

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.