[concurrency-interest] missed deadlines.

Brian Goetz brian at quiotix.com
Tue Jul 11 16:26:14 EDT 2006


>> Re auto-creation of pools, what is wrong with simply starting out with the
>> max-intended size? After all there is no cost associated with idle threads
> is
>> there?
> 
> Sure there is - they use up OS threads, stack space etc. If they didn't we
> wouldn't need thread pools we would just keep as many idle threads as we
> wanted.

Yes, and don't underestimate these costs!

On Linux versions prior to NTPL integration (three or four years ago?) 
there was an OS-imposed limit of less than 1000 threads per process. 
Other OSes may have similar limits.

Even ignoring OS limits, threads use memory and address space for their 
stacks.  Defaults are to use a few hundred K for stack space for each 
thread.  Dividing 256K (probably less than the default) into a 32 bit 
address space yields a hard cap of 16000 threads before you run out of 
address space -- ignoring whether or not you have enough memory to 
actually _use_ the threads.  (And in reality, much of that address space 
is not available to you, so the limit is lower.)

Threads are relatively expensive, that's why they are pooled.


More information about the Concurrency-interest mailing list