using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks; namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<int> source = new List<int>();
for (int i = 0; i < 1000; i++)
{
source.Add(i);
}
Stopwatch stop = new Stopwatch();
stop.Start();
var result = (from x in source.AsParallel().WithDegreeOfParallelism(50)
select proc(x)).ToList();
Console.WriteLine(stop.Elapsed); stop.Stop();
Console.Read(); }
public static int proc(int x) {
Thread.Sleep(100);
return 1;
}
}
}

  耗时12秒 不使用并行 耗时100秒

最新文章

  1. Android Time类 奇葩的设定
  2. 低功耗蓝牙BLE之连接事件、连接参数和更新方法
  3. 使用scala开发spark入门总结
  4. JPHP最新进展 v0.6
  5. 删除已经配置的类库和移除CocoaPods[转]
  6. 网上图书商城项目学习笔记-011Book模块查询(分页)
  7. $HTTP_RAW_POST_DATA
  8. Win8 X64下JDK版本切换问题
  9. BZOJ 3713: [PA2014]Iloczyn( 枚举 )
  10. d3力导向图聚焦
  11. Python常用模块:datetime
  12. 04Vue.js路由系统
  13. CSS实现文字竖排排版
  14. 【前端】js截取or分割字符串的常见方法
  15. Android定位服务关闭和定位(悬浮)等权限拒绝的判断
  16. C/C++常用库及工具
  17. 08.基于IDEA+Spring+Maven搭建测试项目--Maven的配置文件settings.xml
  18. 全国大学API接口分享
  19. 1. EM算法-数学基础
  20. MongoDB安装(一)

热门文章

  1. linux中django部署
  2. 8VC Venture Cup 2016 - Elimination Round F. Group Projects dp
  3. (转)适配器模式--Adapter Pattern
  4. Fatal error: Call to undefined function mb_detect_encoding()
  5. python多线程以及同步队列(转)
  6. 在WPF中使用FontAwesome之类的字体图标
  7. What happens when a SQL Query runs?
  8. 使用tcp.validnode_checking允许、限制机器访问数据库
  9. php根据word模板生成新的word文件
  10. Spring @Autowired 注解不生效