ios-oc-Threads and processes

Source: Internet
Author: User

A thread is an execution unit within a process and an in-process, scheduled entity.

Differences from the process:

1. Address space: An execution unit within a process. A process has at least one thread; they share the address space of the process, and the process has its own separate space.

2. Resource ownership: A process is a resource allocation and owned unit that shares process resources with a thread within the same process.

3. Threads are the basic unit of processor scheduling, but the process is not.

4. Both can be executed concurrently

The difference between a process and a thread:

In short, a program has at least one process, and a process has at least one thread. The thread's dividing scale is smaller than the process, which makes the multi-thread procedure high concurrency. In addition, the process has a separate memory unit during execution, and multiple threads share memory, which greatly improves the efficiency of the program operation. Threads are still different from the process during execution, with each separate thread having a program run entry, sequence execution sequence, and exit of the program. However, a thread cannot execute independently, and it must be dependent on the application in which multiple execution parts can be executed concurrently. However, the operating system does not consider multiple threads as separate applications to implement scheduling and management of processes and resource allocation. This is an important difference between the process and the thread.

A process is a program with a certain independent function about a single run activity on a data set, a process that is an independent unit of the system's resource allocation and scheduling.

A thread is an entity of a process that is the basic unit of CPU dispatch and dispatch, which makes it smaller than the process to run independently. Threads themselves do not have system resources, they have only a few resources (such as program counters, a set of registers and stacks) that are essential in the run, but it can share all the resources owned by the process with other threads of the same process, and one thread can create and revoke another thread ; Multiple threads in a unified process can execute concurrently.

ios-oc-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.