如何很好的回答进程与线程的区别
2011-09-17 17:35
387 查看
这个问题,貌似很简单,但要回答好,却不是那么简单。以下总结下怎么回答这个问题。
step 1:解释进程和线程的概念
进程:a process is an
instance of a
computer program that is being executed. A computer program is a passive collection of instructions; a process is the actual execution of those instructions.Depending on the
operating system (OS), a process may be made up of multiple
threads of execution that execute instructions
concurrently.[1][2]引自wiki
翻译:进程是正在执行的程序的实例。程序只是消极的指令的集合,进程才是指令的真实的执行过程。进程往往由多个并发执行指令的线程组成。
线程:a thread of execution is the smallest unit of processing that can be
scheduled by an
operating system ,Multiple threads can exist within the same process and share resources such as
memory 引自wiki
翻译:线程是操作系统调度的最小的执行单元,多个线程存在于同一个进程中,并共享进程的资源。
step2:简单说下进程和线程的关键不同点
1.同一个进程的多个线程共享内存空间,所以线程之间的通信非常方便。而不同进程因为有各自不同的虚拟空间,所以要进行进程的通信必须采取IPC机制
2.同时,因为线程共享内存空间,所以线程之间需要有好的线程同步的机制,拥有线程的程序会比较复杂。而不同的进程因为地址空间不同,所以相对来说安全。
3.进程是资源分配的基本单位,是一个资源的集合体,线程是CPU调度的最小的单元。
4.线程是轻量级的进程,创建线程和切换线程代价小,适合于并发环境中。
step 1:解释进程和线程的概念
进程:a process is an
instance of a
computer program that is being executed. A computer program is a passive collection of instructions; a process is the actual execution of those instructions.Depending on the
operating system (OS), a process may be made up of multiple
threads of execution that execute instructions
concurrently.[1][2]引自wiki
翻译:进程是正在执行的程序的实例。程序只是消极的指令的集合,进程才是指令的真实的执行过程。进程往往由多个并发执行指令的线程组成。
线程:a thread of execution is the smallest unit of processing that can be
scheduled by an
operating system ,Multiple threads can exist within the same process and share resources such as
memory 引自wiki
翻译:线程是操作系统调度的最小的执行单元,多个线程存在于同一个进程中,并共享进程的资源。
step2:简单说下进程和线程的关键不同点
1.同一个进程的多个线程共享内存空间,所以线程之间的通信非常方便。而不同进程因为有各自不同的虚拟空间,所以要进行进程的通信必须采取IPC机制
2.同时,因为线程共享内存空间,所以线程之间需要有好的线程同步的机制,拥有线程的程序会比较复杂。而不同的进程因为地址空间不同,所以相对来说安全。
3.进程是资源分配的基本单位,是一个资源的集合体,线程是CPU调度的最小的单元。
4.线程是轻量级的进程,创建线程和切换线程代价小,适合于并发环境中。
相关文章推荐
- 进程与线程的区别,简单的图片理解+面试简要回答
- 并发和并行的区别,进程和线程的区别,如何创建线程和线程的四种状态,什么是线程计时器
- 线程和进程的区别?以及如何实现多线程
- java核心知识点学习----并发和并行的区别,进程和线程的区别,如何创建线程和线程的四种状态,什么是线程计时器
- 关于hashmap和hashtable的区别,及如何使hashmap变得线程安全?(除了synchronized)---concurrentHashmap
- 进程与线程的区别 进程的通信方式 线程的通信方式
- 进程和线程的区别
- 浅谈进程与线程的区别
- 进程和线程的区别及联系
- 进程与线程的区别
- 进程和线程关系及区别
- 进程与线程的区别
- 进程和线程关系和区别
- Java 多线程详解(二)------如何创建进程和线程
- 进程与线程的区别联系
- 进程与线程的区别
- 进程与线程的区别,线程安全”怎么理解?(2012.5.6百度实习生笔试)
- 进程和线程的区别
- 进程和线程的区别
- 进程与线程的区别