Threads and requests confusion
If I have a site and each request has its own thr开发者_运维百科ead, does this mean that 1000 visitors will spawn 1000 threads? How does this work (obviously that can't be right)?
Thanks
Threads in ASP.NET are handled via a ThreadPool.
Requests are pooled across the ThreadPool, so each request can be handled by a different thread, but the threads can be reused, preventing the 1000 threads for 1000 requests scenario you mentioned.
For more details, see this CodeProject article on Multi-Threading in ASP.NET.
Yes, it is right. If you have 1 thread per visitor and 1000 visitors that makes for 1000 threads. It may not perform well, but that's another matter.
Fr multi-threaded server applications, you typically have 3 different allocation systems:
- 1 thread for all visitors - each one takes it in turn;
- 1 thread per visitor - obvious;
- a combination fo the 2 - 1 pool of threads (say 10) and visitors get 1 each until thet're all used whereupon new visitors wait.
精彩评论