parallel programming. this causual litery nots represents my recent progress in parallel programming in c#.It`s interesting.
not to say extra words,let`s start the code.
pasted below:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks; namespace paraldemo
{
class Program
{
static void Main(string[] args)
{
var watch = Stopwatch.StartNew();
watch.Start();
var a = ;
var c = ;
String[] names = new string[] { "a", "b" };
Parallel.ForEach(names, d => { Console.Write("paraeel:" + d); });
Parallel.For(, , b => { c += b; });
Parallel.Invoke(() => { Console.WriteLine(); }, () => Console.WriteLine());
Console.WriteLine(c);
watch.Stop();
Console.WriteLine(watch.ElapsedMilliseconds);
var task1 = Task.Factory.StartNew(() => { Console.WriteLine("test task factory"); });
task1.Wait();
var task2 = Task.Factory.StartNew(e => Console.WriteLine("" + e), c);
Task.WaitAll(task1, task2);
Parallel.Invoke(() => Console.WriteLine());
Task.Factory.StartNew(() => Console.WriteLine(), new CancellationTokenSource().Token);
Console.ReadKey();
}
}
}
PLinq
from a in list.AsParallel
parallel programming. this causual litery nots represents my recent progress in parallel programming in c#.It`s interesting.的更多相关文章
- PatentTips - Heterogeneous Parallel Primitives Programming Model
BACKGROUND 1. Field of the Invention The present invention relates generally to a programming model ...
- A Pattern Language for Parallel Application Programming
A Pattern Language for Parallel Application Programming Berna L. Massingill, Timothy G. Mattson, Bev ...
- Task Cancellation: Parallel Programming
http://beyondrelational.com/modules/2/blogs/79/posts/11524/task-cancellation-parallel-programming-ii ...
- Fork and Join: Java Can Excel at Painless Parallel Programming Too!---转
原文地址:http://www.oracle.com/technetwork/articles/java/fork-join-422606.html Multicore processors are ...
- Structured Streaming编程 Programming Guide
Structured Streaming编程 Programming Guide Overview Quick Example Programming Model Basic Concepts Han ...
- Questions that are independent of programming language. These questions are typically more abstract than other categories.
Questions that are independent of programming language. These questions are typically more abstract ...
- Introduction to Parallel Computing
Copied From:https://computing.llnl.gov/tutorials/parallel_comp/ Author: Blaise Barney, Lawrence Live ...
- Python socket – network programming tutorial
原文:https://www.binarytides.com/python-socket-programming-tutorial/ --------------------------------- ...
- An Introduction to Lock-Free Programming
Lock-free programming is a challenge, not just because of the complexity of the task itself, but bec ...
随机推荐
- C语言实例解析精粹学习笔记——28
实例28:从键盘读入实数 题目要求: 编制一个从键盘读入实数的函数readreal(double *rp).函数将读入的实数字符列转换成实数后,利用指针参数rp,将实数存于指针所指向的变量*rp. 思 ...
- POJ:3061-Subsequence(尺取法模板详解)
Subsequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18795 Accepted: 8043 Descript ...
- 奇异值分解(SVD)原理详解及推导
在网上看到有很多文章介绍SVD的,讲的也都不错,但是感觉还是有需要补充的,特别是关于矩阵和映射之间的对应关系.前段时间看了国外的一篇文章,叫A Singularly Valuable Decompos ...
- [Django]我的第一个网页,报错啦~(自己实现过程中遇到问题以及解决办法)
环境配置: python :2.7.13 django:1.10.5 OS:Win7(64位)& Centos7 问题描述 解决办法 global name 'render' is no ...
- 程序员最值得听的歌曲TOP10
No.10 一剪梅 费玉清 - 玉笛公子 <一剪梅>是1984年台湾同名电视剧的片头曲,原唱为林禹胜,经典版本由费玉清演唱,后又成为2009年霍建华.吕一主演电视剧<新一剪梅&g ...
- linux运维笔记
一.查找大文件 sudo find / -size +100M -exec ls -lh {} \;
- 嗯,ACM按照这个一步一步来。
转一个搞ACM需要的掌握的算法. 要注意,ACM的竞赛性强,因此自己应该和自己的实际应用联系起来. 适合自己的才是好的,有的人不适合搞算法,喜欢系统架构,因此不要看到别人什么就眼红, 发挥 ...
- 什么是 IRC?
IRC是Internet Relay Chat 的英文缩写,中文一般称为互联网中继聊天.它是由芬兰人Jarkko Oikarinen于1988年首创的一种网络聊天协议.经过十年的发展,目前世界上有超过 ...
- Python3的unittest用例按编写顺序执行
unittest是Python标准库自带的单元测试框架,是Python版本的JUnit,关于unittest框架的使用,官方文档非常详细,网上也有不少好的教程,这里就不多说了. 本文主要分享在使用un ...
- [译]8-spring bean的作用域
在spring中使用<bean/>标签定义bean的时候,可以使用scope属性来定义bean的作用域.如果想要每次 从spring容器得到一个新创建的bean实例,可以指定scope=& ...