How many threads Parallel.For(Foreach) will create? Default MaxDegreeOfParallelism? How many threads Parallel.For(Foreach) will create? Default MaxDegreeOfParallelism? multithreading multithreading

How many threads Parallel.For(Foreach) will create? Default MaxDegreeOfParallelism?


According to MSDN:

The default scheduler for Task Parallel Library and PLINQ uses the .NET Framework ThreadPool to queue and execute work. In the .NET Framework 4, the ThreadPool uses the information that is provided by the System.Threading.Tasks.Task type to efficiently support the fine-grained parallelism (short-lived units of work) that parallel tasks and queries often represent.

Looking at the documentation of ThreadPool, it says:

There is one thread pool per process. Beginning with the .NET Framework 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.