Android+handler+thread that thing.

Source: Internet
Author: User

 Preface, only began to learn Android more than 10 days, but the thread blocked the pace of progress, because the previous operating system courses did not listen carefully to the teacher lectures, resulting in the understanding of these abstract things some small difficulties. It doesn't matter, the road of hard study, always encounter bumpy, here also to those who lost in the path of the Android niche encourage, learn a little more every day, is to give their greatest gift.

1. There may be a lot of people see this thread is a bit flustered, the noun is a bit tall, I feel so, coincidentally, I think synchronous, asynchronous is also the same, if from a newly-started Android classmate, may be difficult to understand, encounter these problems just want to skip, I am such a person.

2. For Android development, the UI is especially important, if you are powerful, but the interface is really ugly, that's too bad. So Android is particularly focused on the UI main interface, so she has a dedicated main thread, is to wholeheartedly serve him. The UI was beautiful, so I used her, and the main thread was the man behind her.

3. Women always want to show the most beautiful side to others, so behind the money to buy clothes, buy wallets or men-----The main thread, of course, other small men-----sub-thread, there is no qualification, destroy other people's marriage is not qualified, then they do ...

4. In fact, these little men-----child thread, is for the main thread service, the main thread a person busy, so recruit some reliable people to help him. For example, take what express, take what takeout, more time-consuming things, will be handed to the child thread. such as database query Ah, file download Ah, these main thread do not want to run, after all, he also to hurt his wife.

5. How does that sub-thread interact with the main path? For example, you call your classmates to help you take The courier, here has produced a sub-thread, that is, you are not personally to get courier, your classmates play is a sub-thread.

Then, you and your classmates said, 12 points, help me put the express in the dormitory, 1 points, help me to put the courier in the library, 2 points, help me put the courier in the classroom ... Then ask your classmates how to do each time period, these are defined as a handler, each time period is a msg.what, but these have not happened, just anticipate.

6. In fact, your classmates will only pass a time message to you, stating that he has done according to your orders, so this time information is particularly critical, in Android is called a message, in the sub-thread, that is, your classmate's angle, he will sendemptymessage to you, Parameters are the time you define yourself. And as your angle, that is, in the main thread, you define these time messages as Meg.what, and then you update your UI based on time.

7. For example, the main thread is the Yangtze river, sub-thread is a tributary of the Yangtze River, and then Handler is a tributary to the Yangtze River Bridge, the Yangtze River sent a handler Messenger to monitor the completion of the work of tributaries, and then the tributary call Msg.what tell the situation here, and then the Yangtze River continues to flow east, update the UI

8. Finally write a motivational word-----Since you choose, you will disregard the trials and hardships! Late Ansmida-----2017/7/10 0:30

Android+handler+thread that thing.

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.