Difference between AppDomain, Assembly, Process, and a Thread

后端 未结 2 911
予麋鹿
予麋鹿 2020-12-12 16:29

What is the difference between AppDomain, Assembly, Process, and a Thread?

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 16:49

    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.

    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.

    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)...

    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.

提交回复
热议问题