Introduction to iOS Multithreading

Source: Internet
Author: User

1. Process
    • What is a process
    • A process is an application that is running in the system
    • Each process is independent, and each process runs within its dedicated and protected memory space
    • For example, to open the Thunder, Xcode, the system will start 2 processes respectively
2. Threads
    • What is a thread
    • 1 processes to perform a task, a thread must be wired (at least 1 threads per 1 processes)
    • All tasks for a process (program) are executed in the thread
    • For example, using a cool dog to play music, using Thunder to download movies, all need to execute in the thread

3, the thread of the serial
    • The execution of a task in 1 threads is serial
    • If you want to perform multiple tasks in 1 threads, you can perform these tasks sequentially, one at a-
    • That is, at the same time, 1 threads can only perform one task
    • For example, download 3 files in 1 threads (file A, file B, file C, respectively)
    • As a result, threads can also be thought of as 1 execution paths in a process

4. Multithreading
    • What is multithreading
    • Multiple threads can be opened in 1 processes, each thread can perform different tasks in parallel (at the same time)
    • If that process is? Shop n, Thread is? Workshop workers
    • Multithreading technology can improve the efficiency of program execution
    • For example, the simultaneous opening of 3 threads to download 3 files (file A, file B, file C, respectively)

5. Advantages and disadvantages of multithreading
    • Advantages of multithreading
    • To improve the execution efficiency of the program appropriately
    • Can appropriately improve resource utilization (CPU, memory utilization)
    • Disadvantages of multithreading
    • The cost of creating threads is that the main costs under iOS include: Kernel data structures (approximately 1KB), stack space (sub-thread 512KB, main thread 1MB, or-setstacksize: set, but must be a multiple of 4K, and the minimum is 16K), Create thread takes approximately 90 milliseconds to create time
    • If a large number of threads are turned on, the performance of the program is reduced
    • The more threads, the greater the overhead of the CPU on the dispatch thread
    • Programming is more complex: such as communication between threads, multi-threaded data sharing
6. Multi-Threading implementation in iOS

Introduction to iOS Multithreading

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.