using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Parallel.For(, ,
i => Console.WriteLine("The square of {0} is {1}", i, i * i)); const int maxValues = ;
int[] squares = new int[maxValues]; Parallel.For(, maxValues,
i => squares[i] = i * i); for (var i = ; i < maxValues; i++)
{
Console.WriteLine(squares[i]);
} Console.WriteLine("==========================================");
string[] words = new string[] { "We", "hold", "there", "to", "be", "self-evident" }; Parallel.ForEach(words,
i => Console.WriteLine($"{i} has {i.Length}"));//和For的区别是:For需要索引号,ForEach不需要 /*
The square of 0 is 0
The square of 6 is 36
The square of 5 is 25
The square of 1 is 1
The square of 4 is 16
The square of 13 is 169
The square of 3 is 9
The square of 11 is 121
The square of 12 is 144
The square of 14 is 196
The square of 2 is 4
The square of 8 is 64
The square of 10 is 100
The square of 9 is 81
The square of 7 is 49
0
1
4
9
16
25
36
49
64
81
100
121
144
169
196
225
256
289
324
361
400
441
484
529
576
625
676
729
784
841
900
961
1024
1089
1156
1225
1296
1369
1444
1521
1600
1681
1764
1849
1936
2025
2116
2209
2304
2401
==========================================
We has 2
self-evident has 12
to has 2
there has 5
hold has 4
be has 2
请按任意键继续. . . */
}
}
}

C#4并行计算的更多相关文章

  1. 并行计算提升32K*32K点(32位浮点数) FFT计算速度(4核八线程E3处理器)

    对32K*32K的随机数矩阵进行FFT变换,数的格式是32位浮点数.将产生的数据存放在堆上,对每一行数据进行N=32K的FFT,记录32K次fft的时间. 比较串行for循环和并行for循环的运行时间 ...

  2. [信安Presentation]一种基于GPU并行计算的MD5密码解密方法

    -------------------paper--------------------- 一种基于GPU并行计算的MD5密码解密方法 0.abstract1.md5算法概述2.md5安全性分析3.基 ...

  3. 用Python实现多核心并行计算

    平常写的程序,无论是单线程还是多线程,大多只有一个进程,而且只能在一个核心里工作.所以很多应用程序即使正在满载运行,在任务管理器中CPU使用量还是只有50%(双核CPU)或25%(四核CPU) 如果能 ...

  4. java并行计算Fork和Join的使用

    Java在JDK7之后加入了并行计算的框架Fork/Join,可以解决我们系统中大数据计算的性能问题.Fork/Join采用的是分治法,Fork是将一个大任务拆分成若干个子任务,子任务分别去计算,而J ...

  5. #研发解决方案#分布式并行计算调度和管理系统Summoner

    郑昀 创建于2015/11/10 最后更新于2015/11/12 关键词:佣金计算.定时任务.数据抽取.数据清洗.数据计算.Java.Redis.MySQL.Zookeeper.azkaban2.oo ...

  6. .NET并行编程实践(一:.NET并行计算基本介绍、并行循环使用模式)

    阅读目录: 1.开篇介绍 2.NET并行计算基本介绍 3.并行循环使用模式 3.1并行For循环 3.2并行ForEach循环 3.3并行LINQ(PLINQ) 1]开篇介绍 最近这几天在捣鼓并行计算 ...

  7. Parallel类实现并行计算

    https://msdn.microsoft.com/zh-cn/ff652648.aspx 图像处理——并行计算的应用实例 http://blog.csdn.net/bitfan/article/d ...

  8. 基于MPI的并行计算—矩阵向量乘

    以前没接触过MPI编程,对并行计算也没什么了解.朋友的期末课程作业让我帮忙写一写,哎,实现结果很一般啊.最终也没完整完成任务,惭愧惭愧. 问题大概是利用MPI完成矩阵和向量相乘.输入:Am×n,Bn× ...

  9. 【转】【C#】【Thread】【Parallel】并行计算

    并行计算 沿用微软的写法,System.Threading.Tasks.Parallel类,提供对并行循环和区域的支持. 我们会用到的方法有For,ForEach,Invoke. Program.Da ...

  10. 并行计算之OpenMP中的任务调度

    本文参考<OpenMP中的任务调度>博文,主要讲的是OpenMP中的schedule子句用法. 一.应用需求 在OpenMP并行计算中,任务调度主要用于并行的for循环.当for循环中每次 ...

随机推荐

  1. JDBC学习(含转载)

    首先连接数据库: Class.forName("com.mysql.jdbc.Driver");//加载jdbc驱动 Connection conn=DriverManager.g ...

  2. WindowsPE权威指南 第二章 小工具 PEInfo代码的C语言实现

    主程序代码 PEInfo.c #include <Windows.h> #include<Richedit.h> #include "resource.h" ...

  3. spring深入学习(四)-----spring aop

    AOP概述 aop其实就是面向切面编程,举个例子,比如项目中有n个方法是对外提供http服务的,那么如果我需要对这些http服务进行响应时间的监控,按照传统的方式就是每个方法中添加相应的逻辑,但是这些 ...

  4. 微信小程序的自定义插件

    第一步,创建一个页面和普通页面一样 第二不,在这个页面上进行对json配置, "component":true 第三不在需要插入的页面中进行设置 插入标签 <dialog i ...

  5. Eclipse搭建SSH框架(Struts2+Spring+Hibernate)

    见识少的我经过一天多的研究才知道,在MyEclipse中搭好的框架的配置文件和jar包是通用的.接下来——亮剑! 工具:Eclipse+Tomcat+Mysql 一.先在Eclipse中配置好Tomc ...

  6. BP神经网络 详解模板

    %原始数据输入 P=[ - 6.142 - 27.5 5.068 - 31.7 5.196 - 34.1 6.362 - 31.54 6.472 - 30.17 6.578 - 29.53 6.351 ...

  7. Base64格式上传文件至阿里云(java)

    Controller @PostMapping("/save") public R save(@RequestBody ShareEntity share){ OSSClient ...

  8. La nuova tecnologia del puntatore laser

    Il potente puntatore laser 20000 mW viene fornito di serie con gestione termica e driver laser di qu ...

  9. Django关联数据库时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'

    sgrade = models.ForeignKey("Grades",) 执行python manage.py makemigrations后出现TypeError: __ini ...

  10. 00SQL表字段说明

    SELECT d.name 表名 , a.colorder 字段序号 , a.name 字段名 , ISNULL(g.[value], '') AS 字段说明 , ( CASE WHEN COLUMN ...