试了一下.Net Fx 4.0中的Parallel        static string[] arr = Directory.GetFiles(
试了一下.Net Fx 4.0中的Parallel                                          
@"C:\Users\Public\Pictures\Sample Pictures"
试了一下.Net Fx 4.0中的Parallel                                          
"*.jpg");
试了一下.Net Fx 4.0中的Parallel
试了一下.Net Fx 4.0中的Parallel        
//这里Spin的数值最好自行modify一下,我的是Q6600的机子 

采用并行的Foreach效果的确很明显.不仅仅是指派了多个线程,对cpu的利用率也高很多,
见下面两图比较:
原来的foraech:
试了一下.Net Fx 4.0中的Parallel
使用parallel的foreach:
试了一下.Net Fx 4.0中的Parallel

有兴趣的朋友可以对parallel相应的类库做一下逆向工程分析一下it的原理;-)

 

相关文章:

  • 2022-01-03
  • 2021-07-31
  • 2021-09-19
  • 2021-08-21
  • 2021-12-04
  • 2021-10-31
  • 2021-10-08
  • 2021-06-18
猜你喜欢
  • 2021-11-05
  • 2022-02-13
  • 2021-05-28
  • 2021-06-13
  • 2021-11-13
  • 2022-01-09
  • 2022-02-28
相关资源
相似解决方案