android-Multithreading and asynchronous overview and face questions

Source: Internet
Author: User

android-Multithreading and Asynchronous Overview
multithreading in a Java
Runable
Thread
Threadpoolexector
Scheduleexector

Thread synchronization
Synchronized synchronization
Lock locks
Semaphore Signal Volume

two using multithreading in Android
1, why use multithreading
IO operations: File, network, database

Complex operations

Timed operation

For time-consuming operations, it should be run on a non-main thread to avoid blocking the main thread
To ensure a good user experience,
Recommended for more than 50ms (1000ms/50ms = 20FPS for the human eye to see the smooth picture of the minimum number of frames)
Operations are handled using threading

2, how to use multi-threaded or asynchronous, used classes
Thread
Handle
Asynctask
Asynctaskloader (used after Android 3.0)
(Cursorloader)

3, multithreading and interface interaction in the way that used to the class
Activity.runonuithread (runable)

View.post (runable)
View.postdelay (runable, long)

Handle

Asynctask

4,android UI Main thread simple principle
Do not block UI Thread
Do not manipulate the UI directly outside the UI thread

Precautions :
Async equals Multithreading
Android does not allow the UI to change directly in multiple threads

Interview questions:
1,android How is multithreading implemented?
Threads and thread pools to implement

What are the ways to implement 2,android asynchronous tasks?
Asynctask
Asynctaskloader

3,android How to ensure thread safety of the UI?
Any code that operates the UI is placed in the UI thread

Copyright NOTICE: Welcome to Exchange, QQ872785786

android-Multithreading and asynchronous overview and face questions

Related Article

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.