Alex Rivera | Logout

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

Asked 2009-01-27T00:12:56.380
32

Does anyone know? And a bigger question is what happens when you encounter this maximum? Is this the same number with other Windows OSs such as Vista, XP etc.?

Edit
Report

2 Answers

37

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)

answered 2009-01-27T00:21:26.380
26

The best answer I've heard when asking such questions is:

It doesn't matter, and if you find that it does matter, you need to rethink what you're doing so that it doesn't matter.

answered 2009-01-27T00:23:46.920

Your Answer