我觉得问题很清楚了。 PLinq 不允许您创建超过 63 个线程(WithDegreeOfParallelism 不允许,抛出 ArgumentOutOfRangeException)。在极少数情况下,我们需要从线程池中获取超过 63 个线程(例如 I/O 操作,其中任务需要比平时更多的时间才能完成)。据我所知,Parallel 类也有同样的限制。有什么解决方法吗?这种限制的原因是什么?
最佳答案
引自this link :
With Parallel.For/ForEach, there's no implicit limit, however the ThreadPool in .NET 4 (which Parallel.For/ForEach target by default) will only use up to 64 logical processors. PLINQ in .NET 4 does have hard-coded limit of 63 partitions. As larger and larger machines become available, I expect you'll see such limitations removed, just as how with the latest versions of Windows the OS supports up to 256 logical processors.
关于c# - 为什么 PLinq 不支持超过 63 个并行线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6003094/