Multi-threaded essay Knowledge Point summary 2

Source: Internet
Author: User
Multithreading principle

1. Use multi-threaded purpose: The time-consuming operation in the background to execute, after the completion of execution, notify the main thread to update the UI

2. Principle:

Single Core CPU: At the same time, the CPU can only process one thread, in other words, at the same time only one thread is executing

Multi-threaded simultaneous execution: The CPU is fast switching between multiple threads; CPU Scheduler threads are fast enough to result in multi-threaded simultaneous execution

If there are a lot of threads: the CPU switches between n threads, consumes a lot of CPU resources, the number of times each thread is dispatched is reduced, and the execution of the thread is less efficient.

3. Advantages and disadvantages of multithreading

Advantages: It can improve the execution efficiency of the program; Increase resource utilization (CPU, memory)

Cons: Open threads need to occupy a certain amount of memory (by default, each thread occupies 512kb--ios8.0 and the default stack of the main thread is 512KB)

If you open a large number of threads, will take up a lot of space, reduce the performance of the program, the CPU on the scheduling thread of the greater the cost

Threads are more complex in program logic, such as inter-thread communication and multi-threaded data sharing

4. Multi-threaded implementation scheme

Multi-threaded essay Knowledge Point summary 2

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.