Why is Parallel.ForEach much faster then AsParallel().ForAll() even though MSDN suggests otherwise?

后端 未结 4 939
迷失自我
迷失自我 2020-11-28 08:51

I\'ve been doing some investigation to see how we can create a multithreaded application that runs through a tree.

To find how this can be implemented in the best wa

4条回答
  •  佛祖请我去吃肉
    2020-11-28 09:21

    Based on the accepted answer to How exactly does AsParallel work?

    .AsParallel.ForAll() casts back to IEnumerable before calling .ForAll()

    so it creates 1 new thread + N recursive calls (each of which generates a new thread).

提交回复
热议问题