The differences and connections between iOS threads and processes

Source: Internet
Author: User

The main difference between threads and processes is that they are different ways to manage operating system resources. The process has a separate address space, and after a process crashes, it does not affect other processes under the influence of protected mode, and the thread is just a different execution path in a process. Thread has its own stack and local variables, but there is no separate address space between the threads, a thread dead is equivalent to the entire process of death, so the multi-process program is more robust than multithreaded programs, but in the process of switching, the cost of large resources, efficiency is worse. But for some concurrent operations that require simultaneous and shared variables, only threads can be used, and processes cannot be used.

Threads are the basic unit of CPU-independent operation and independent dispatch (which can be understood as a snippet of code executed in a process).

A process is the basic unit of resource allocation (a process is an area of memory that contains some resources).

Processes and threads are the basic units that the operating system realizes, and the system uses this basic unit to realize the concurrency of the system to the application. A process is a container of threads that actually completes the thread that executes the code, and the process acts as the execution environment for the thread. A program contains at least one process, a process that contains at least one thread, and all threads in a process share the resources owned by the current process.

The differences and connections between iOS threads and processes

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.