Reputation: 85471
Starting with Windows Vista, every application automatically gets a thread pool (the "default thread pool").
My Question is: is there a way to configure the min and max number of threads for this default thread pool?
SetThreadpoolThreadMaximum
seems to work only for a non-default thread pool (a pool created with CreateThreadpool
):
SetThreadpoolThreadMaximum(NULL, 4);
- throws 0xC000000D: An invalid parameter was passed to a service or function
Upvotes: 2
Views: 1697
Reputation: 85471
According to Joe Duffy from Microsoft, this is not possible.
Here's a quote from his book, Concurrent Programming on Windows, chapter 7. Thread Pools, page 345:
Note that it is not possible to alter the default thread pool's minimum and maximum count; instead, you must specify a pointer to a custom
TP_POOL
object. Prior to Vista, you could change the process-wide default pool's maximum (as we see later). The reason this capability has been removed is because it depends on races: the last component to call the API would win. This can cause conflicts between components in the same process that are unaware of each other but want different maximum or minimum values.
The "old way" of increasing the pool size the author is referring to is the macro WT_SET_MAX_THREADPOOL_THREADS
, used in QueueUserWorkItem
. That setting seems to be ignored in the new pool architecture.
So the default pool's minimum is fixed at 0 and the maximum is 500.
Upvotes: 1