Application Domains represent the unit of code unloading in the NGWS runtime. We do not provide for unloading of code at a more granular level than a domain, such as a class or an assembly.
Each domain is a process can be unloaded independently of the others using the Unload method on System.AppDomain.
A new domain runs on the same thread as the code that created it. There is not a one to one correspondence between threads and domains. Web server scenarios can require hundreds of domains per process, whereby the ideal number of threads is some small multiple of the number of processors on the machine.
At any given time, every thread is executing in one domain. The NGWS runtime keeps track of which threads are running in which domains. This information, coupled with the fact that direct references are not allowed between domains, allows the NGWS runtime to provide clean shutdown. When a shutdown request is made, the runtime unwinds the thread until it gets to the domain boundary. At this point, it can "detach" all proxies to objects in other domains.