Android program and server-side interaction Summary

Source: Internet
Author: User

One, Android thread

1. Main thread

When the application starts, the system creates a main thread, also known as the UI thread, which is primarily responsible for processing the user interface, distributing events to the appropriate user interface, and interacting with the Android UI component package. Try not to handle long-consuming operations such as network traffic, querying databases, etc. in the UI line thread, as they may block the entire process, and once the UI thread is blocked for more than a certain amount of time (currently about 5s), the user is prompted with "ANR" (the application is not responding).

The UI component of Android is not thread-safe, so the user interface is not allowed to operate from a worker thread, but only from the main thread.

As a result, the single-threaded mode of Android must adhere to the following two principles: (1) do not block the UI thread (2) do not access the Android UI component package outside the UI thread.

2. Worker threads

Android program and server-side interaction Summary

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.