A thread is sometimes called a lightweight process, which is a smaller unit of activity than a process, and it is an execution path in the process. A process can have multiple execution paths that are threads.
The main differences between threads and processes:
1. A thread is an integral part of a process, a process can have multiple threads, and at least one thread can execute.
2, the process is the basic unit of resource allocation, he has his own address space and a variety of resources. A thread is the basic unit of a processor's dispatch, and he can only share the resources of a process with other threads, without any resources of its own.
3. Multiple threads of a process are active in the address space of the process.
4, the thread and the process, all have their own state and the corresponding synchronization mechanism. However, because the thread does not have its own separate program and data space, it cannot be exchanged to the outer village like the program and data of the process.
5. Because threads within the same process share memory and files. So they communicate with each other without calling the kernel.
6, the process of scheduling and control is mostly done by the operating system kernel, and the control of the thread can be done by the operating system kernel, or by the user control.
What is a thread and what is the difference between a thread and a process?