"You cannot set the number of worker threads or the number of I/O completion threads to a number smaller than the number of processors in the computer." (Threadp开发者_如何学编程ool.SetMaxThreads)
What if I need to have less threads (I'm using a resource which does not support more than 4 threads from one process)? is there a way to set the maximum to 4 for an 8 core box? I'm using Tasks in C#.
it seems you should try to limit the number of threads with access to that resource rather than the total number of threads this could be done by locking or tickets
Yes, Microsoft has such requirement that number of thread cannot be smaller than the number of processors. More info here.
I am interested to know why does Microsoft have such requirement? It should be harmless isn't it ? This requirement does not make sense...
just tried this out, and this "requirement" seems to be incorrect. i believe that it merely sets MinThreads to the # of cores in your machine by default. if i do this:
ThreadPool.SetMinThreads(1, 1);
ThreadPool.SetMaxThreads(2,2);
on a QuadCore machine, it seems to throttle the thread execution properly, if i leave out the SetMinThreads call though, it ignores my call to SetMaxThreads (since you cant set MaxThreads to less than MinThreads (which is # of cores by default))
精彩评论