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