Process
A process represents an application running on the operating system.Program. A process has its own block, exclusive resources and data, and can be scheduled by the operating system. Even if the same application is forced to start multiple times, it will be installed in an inaccessible process and run independently.
Thread
A thread is also called a microprocess or a lightweight process. It is similar to a process. It is a scheduling Unit and maintains its own stack and Context Environment. A thread is affiliated with a process. A process can contain one or more threads, and multiple threads in the same process share a memory block and resources. A thread is a basic unit that can be scheduled by an operating system. At the same time, its scheduling is limited by the processes that contain the thread. That is to say, the operating system first decides the next process to be executed, then the thread in the process will be scheduled.
Differences between threads and processes
The biggest difference between a thread and a process is isolation. Each process is isolated independently, with its own memory block, exclusive resources and running data. The crash of a process does not affect other processes, and interaction between processes is quite difficult. Unlike a process, threads in a process share resources and memory blocks, and one thread can access and end other threads in the same process.
Optical Fiber
A thread is a lightweight thread concept proposed by Microsoft. A fiber has its own stack and register status. A thread can contain multiple fiber threads. Different from a thread called by the operating system, the scheduling of fiber threads in a thread is completely controlled by the programmer, the operating system kernel does not know the existence of the fiber.