问题描述
AppDomain ,程序集,过程和线程之间有什么区别?
What is the difference between AppDomain, Assembly, Process, and a Thread?
推荐答案
AppDomain是流程中的隔离单元。 AppDomains可以在运行时创建,加载代码和卸载。它的隔离边界旨在使.NET应用程序更可靠。
An AppDomain is an isolation unit within a process. AppDomains can be created at runtime, loaded with code, and unloaded. Its an isolation boundary designed to make .NET apps more reliable.
程序集包含一个或多个模块,这些模块包含编译后的代码块。通常,程序集将显示为.EXE或.DLL。
An assembly holds one or more modules, which hold compiled chunks of code. You will typically see an assembly as an .EXE or a .DLL.
进程是一个正在执行的应用程序(waaaay简化了)。
A process is an executing application (waaaay oversimplified).
线程是一个执行上下文。操作系统在线程内执行代码。操作系统在线程之间进行切换,从而允许每个线程依次执行,从而给人以为多个应用程序正在同时运行。
A thread is an execution context. The operating system executes code within a thread. The operating system switches between threads, allowing each to execute in turn, thus giving the impression that multiple applications are running at the same time.
将它们组合在一起(非常简化)...
To put it all together (very simplified)...
程序已执行。进程由操作系统创建,并在其单线程内开始加载要执行的代码。在.NET应用程序中,CLR创建单个AppDomain。应用程序的执行程序集(.EXE)已加载到此AppDomain中并开始执行。该应用程序可以生成新进程,创建AppDomain,将其他程序集加载到这些域中,然后创建新的线程以在任何这些AppDomain中执行代码。
A program is executed. A process is created by the operating system, and within its single thread it starts loading code to execute. In a .NET application, a single AppDomain is created by the CLR. The application's executing assembly (the .EXE) is loaded into this AppDomain and begins execution. The application can spawn new processes, create AppDomains, load other assemblies into these domains, and then create new Threads to execute code in any of these AppDomains.
这篇关于AppDomain,程序集,进程和线程之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!