What’s the maximum number of threads in Windows Server 2003?

First I would advise reading this:
http://blogs.msdn.com/oldnewthing/archive/2007/03/01/1775759.aspx

then http://blogs.msdn.com/oldnewthing/archive/2005/07/29/444912.aspx

To summarise, the limitation is normally stack space (which must be in contiguous blocks) and since every thread consumes this scattered about you rapidly run out of contiguous blocks.
On 64 bit machines and operating systems this is much less of a problem.

Mitigation strategies exist but will only go so far (and rely on you not using much stack per thread)

As a rough guide:

  • creating tens is almost certain to work
  • hundreds is probable on current server and desktop hardware but risky
  • thousands will almost certainly fail.

You likely shouldn’t need to create more than ten anyway (and if you really do need to you should know this information already)

Leave a Comment