ThreadPool的疑问
1.线程池在首次创建 ThreadPool 类的实例时被创建。
线程池具有每个可用处理器 25 个线程的默认限制。
2.bool bSetMaxThread = ThreadPool.SetMaxThreads(200, 500);
这两句话是否有矛盾,请帮忙解答下原因。
------解决方案--------------------线程池具有每个可用处理器 25 个线程的默认限制。
------解决方案--------------------在.net4.0以后,这个数量已经不是25了,而是1000多。说它“默认25个线程”是老皇历了。
------解决方案--------------------
Net 4的解释:
There is one thread pool per process. Beginning with the .NET Framework version 4, the default size of the thread pool for a process depends on several factors, such as the size of the virtual address space. A process can call the GetMaxThreads method to determine the number of threads. The number of threads in the thread pool can be changed by using the SetMaxThreads method. Each thread uses the default stack size and runs at the default priority.
default size不再是25了。而且可以使用SetMaxThreads修改这个值。