线程/进程/任务之间有什么区别? [英] What is the difference between a thread/process/task?

查看:70
本文介绍了线程/进程/任务之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

线程/进程/任务之间有什么区别?

What is the difference between a thread/process/task?

推荐答案

流程:

进程是正在执行的计算机程序的一个实例.它包含程序代码及其当前活动.根据操作系统 (OS),一个进程可能由多个并发执行指令的执行线程组成.基于进程的多任务处理使您能够在使用文本编辑器的同时运行 Java 编译器.在单个 CPU 中使用多个进程时,使用了各种内存上下文之间的上下文切换.每个进程都有一套完整的自己的变量.

Process:

A process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently. Process-based multitasking enables you to run the Java compiler at the same time that you are using a text editor. In employing multiple processes with a single CPU,context switching between various memory context is used. Each process has a complete set of its own variables.

线程是 CPU 利用率的基本单位,由程序计数器、堆栈和一组寄存器组成.一个执行线程从一个计算机程序分叉到两个或多个并发运行的任务中产生.线程和进程的实现因操作系统而异,但在大多数情况下,线程包含在进程中.多个线程可以存在于同一个进程中并共享内存等资源,而不同的进程不共享这些资源.同一进程中的线程示例是自动拼写检查和写入时自动保存文件.线程基本上是在同一内存上下文中运行的进程.线程在执行时可以共享相同的数据.线程图,即单线程与多线程

A thread is a basic unit of CPU utilization, consisting of a program counter, a stack, and a set of registers. A thread of execution results from a fork of a computer program into two or more concurrently running tasks. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources. Example of threads in same process is automatic spell check and automatic saving of a file while writing. Threads are basically processes that run in the same memory context. Threads may share the same data while execution. Thread Diagram i.e. single thread vs multiple threads

任务是一组加载到内存中的程序指令.

A task is a set of program instructions that are loaded in memory.

这篇关于线程/进程/任务之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆