AsParallel.ForAll vs Parallel.ForEach

前端 未结 4 1150
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-31 15:11

Is there any difference between the below code snippets. If so, what?

myList.AsParallel().ForAll(i => { /*DO SOMETHING*/ });

and

Pa

4条回答
  •  温柔的废话
    2021-01-31 15:58

    As written in Concurrency in C# Cookbook:

    One difference between Parallel and PLINQ is that PLINQ assumes it can use all of the cores on the computer, while Parallel will dynamically react to changing CPU conditions.

提交回复
热议问题