title: How many threads Parallel.For(Foreach) will create? Default MaxDegreeOfParallelism?
body: <p>I want to know, how many threads will be used when I run Parallel.For/ForEach loop.</p>
  
  <p>I found, that it can be changed by MaxDegreeOfParallelism option.</p>
  
  <p>MaxDegreeOfParallelism help on MSDN says (<a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.paralleloptions.maxdegreeofparallelism.aspx">link</a>):</p>
  
  <blockquote>
    <p>By default, For and ForEach will utilize however many threads the
    underlying scheduler provides, so changing MaxDegreeOfParallelism from
    the default only limits how many concurrent tasks will be used.</p>
  </blockquote>
  
  <p>But I don't know how many threads underlying scheduler provides. </p>
  
  <p><strong>How can I find out that?</strong> </p>
  
  <p>I could test it with loop with 9999999 runs, however this test will show me number, but not the rule that determine that number.</p>
  
  <p>Edit/added later:</p>
  
  <p>I googled for "sheduler max concurrency", and I found (at MSDN - <a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.taskscheduler.maximumconcurrencylevel.aspx">link</a>), that <code>TashSheduler</code> class has <code>MaximumConcurrencyLevel</code> property, and:</p>
  
  <blockquote>
    <p>Returns an integer that represents the maximum concurrency level. The
    default scheduler returns Int32.MaxValue.</p>
  </blockquote>
  
  <p><strong>That TaskSheduler class is used as "underlying scheduler" for these parallel loops?</strong></p>