C#4并行计算
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并行计算的更多相关文章
- 并行计算提升32K*32K点(32位浮点数) FFT计算速度(4核八线程E3处理器)
对32K*32K的随机数矩阵进行FFT变换,数的格式是32位浮点数.将产生的数据存放在堆上,对每一行数据进行N=32K的FFT,记录32K次fft的时间. 比较串行for循环和并行for循环的运行时间 ...
- [信安Presentation]一种基于GPU并行计算的MD5密码解密方法
-------------------paper--------------------- 一种基于GPU并行计算的MD5密码解密方法 0.abstract1.md5算法概述2.md5安全性分析3.基 ...
- 用Python实现多核心并行计算
平常写的程序,无论是单线程还是多线程,大多只有一个进程,而且只能在一个核心里工作.所以很多应用程序即使正在满载运行,在任务管理器中CPU使用量还是只有50%(双核CPU)或25%(四核CPU) 如果能 ...
- java并行计算Fork和Join的使用
Java在JDK7之后加入了并行计算的框架Fork/Join,可以解决我们系统中大数据计算的性能问题.Fork/Join采用的是分治法,Fork是将一个大任务拆分成若干个子任务,子任务分别去计算,而J ...
- #研发解决方案#分布式并行计算调度和管理系统Summoner
郑昀 创建于2015/11/10 最后更新于2015/11/12 关键词:佣金计算.定时任务.数据抽取.数据清洗.数据计算.Java.Redis.MySQL.Zookeeper.azkaban2.oo ...
- .NET并行编程实践(一:.NET并行计算基本介绍、并行循环使用模式)
阅读目录: 1.开篇介绍 2.NET并行计算基本介绍 3.并行循环使用模式 3.1并行For循环 3.2并行ForEach循环 3.3并行LINQ(PLINQ) 1]开篇介绍 最近这几天在捣鼓并行计算 ...
- Parallel类实现并行计算
https://msdn.microsoft.com/zh-cn/ff652648.aspx 图像处理——并行计算的应用实例 http://blog.csdn.net/bitfan/article/d ...
- 基于MPI的并行计算—矩阵向量乘
以前没接触过MPI编程,对并行计算也没什么了解.朋友的期末课程作业让我帮忙写一写,哎,实现结果很一般啊.最终也没完整完成任务,惭愧惭愧. 问题大概是利用MPI完成矩阵和向量相乘.输入:Am×n,Bn× ...
- 【转】【C#】【Thread】【Parallel】并行计算
并行计算 沿用微软的写法,System.Threading.Tasks.Parallel类,提供对并行循环和区域的支持. 我们会用到的方法有For,ForEach,Invoke. Program.Da ...
- 并行计算之OpenMP中的任务调度
本文参考<OpenMP中的任务调度>博文,主要讲的是OpenMP中的schedule子句用法. 一.应用需求 在OpenMP并行计算中,任务调度主要用于并行的for循环.当for循环中每次 ...
随机推荐
- String常用类
一.String类String类在java.lang包中,java使用String类创建一个字符串变量,字符串变量属于对象.java把String类声明的final类,不能有类.String类对象创建 ...
- HTTP协议 与 TCP协议 的区别
TCP协议是传输层协议,主要解决数据如何在网络中传输,而HTTP是应用层协议,主要解决如何包装数据. TCP/IP和HTTP协议的关系,从本质上来说,二者没有可比性,我们在传输数据时,可以只使用(传输 ...
- laravel 对接 UCenter 基础
说明:1,运行环境 laravel 5.3 php7+nginx+mysql 2,使用安装包 https://github.com/goodspb/laravel5-ucenter 上面有对接方 ...
- mysql无密码登陆
mysql登陆不上或者密码忘记可以尝试一下无密码登陆 以下一波神操作!! 首先关闭数据库服务(数据库在Centos7版本以上或者Redhat版本上被改名为mariadb) systemctl stop ...
- HTML5标签汇总及知识学习线路总结
HTML5标签汇总,以及知识学习线路总结.
- Sqlalchemy python经典第三方orm
Ⅰ. 安装 pip install sqlalchemy Ⅱ. 起步链接 import time import threading import sqlalchemy from sqlalchemy ...
- 怎么取cxgrid某一列的合计值
怎么取cxgrid某一列的合计值 1.cxGrid1DBTableView1->optionsview->Footer 设为True 2.cxGrid1DBTableView1-> ...
- C++面试基础概念之动态库篇
编写DLL所学所思(1)——导出函数 编写DLL所学所思(2)——导出类 C++ DLL导出类 知识大全 C++类库开发详解
- [转] List of OpenFlow Software Projects
List of OpenFlow Software Projects (that I know of) http://yuba.stanford.edu/~casado/of-sw.html (I a ...
- EmguCV使用Stitcher类来拼接图像
using System; using System.Windows; using System.Collections.Generic; using System.ComponentModel; u ...