Difference between Process and Thread
线程&进程不同点:
What is a Process?
- A process is the execution of a program that allows you to perform
the appropriate actions specified in a program. - It can be defined as an execution unit where a program runs.
- The OS helps you to create, schedule, and terminates the processes
which is used by CPU. - The other processes created by the main process are called child
process.
What is Thread?
- Thread is an execution unit that is part of a process.
- A process can have multiple threads, all executing at the same time.
- It is a unit of execution in concurrent(同时) programming.
- A thread is lightweight and can be managed independently by a scheduler.
- It helps you to improve the application performance using parallelism.
进程:指在系统中正在运行的一个应用程序;程序一旦运行就是进程;
进程——资源分配的最小单位。
线程:系统分配处理器时间资源的基本单元,或者说进程之内独立执行的一个单元执行流。
线程——程序执行的最小单位。
小结:
1.进程要分配一大部分的内存,而线程只需要分配一部分栈就可以了.
2.一个程序至少有一个进程,一个进程至少有一个线程.
3.进程是资源分配的最小单位,线程是程序执行的最小单位。
4.一个线程可以创建和撤销另一个线程,同一个进程中的多个线程之间可以并发执行.