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 ...
随机推荐
- 【PHP项目】【Smarty】Smarty截取字符串方法truncate
smarty truncate 截取字符串 //在sql中truncate是删除表格(truncate是只删除内容,delete彻底删除)从字符串开始处截取某长度的字符,默认的长度为80指定第二个参 ...
- python中的字典内置方法小结
#!/usr/local/bin/python3 # -*- coding:utf-8 -*- #key-value #dict 无序,无下标,不需要下标,因为有key stu={ 'stu001': ...
- 数据结构学习-AVL平衡树
环境:C++ 11 + win10 IDE:Clion 2018.3 AVL平衡树是在BST二叉查找树的基础上添加了平衡机制. 我们把平衡的BST认为是任一节点的左子树和右子树的高度差为-1,0,1中 ...
- python 初学函数
#len # s = '金老板小护士' # len(s) # def my_len(): #自定义函数 # i = 0 # for k in s: # i += 1 # print(i) # # le ...
- Codeforces Round #458C DP
C. Travelling Salesman and Special Numbers time limit per test 1 second memory limit per test 256 me ...
- python基础之继承派生、组合、接口和抽象类
类的继承与派生 经典类和新式类 在python3中,所有类默认继承object,但凡是继承了object类的子类,以及该子类的子类,都称为新式类(在python3中所有的类都是新式类) 没有继承obj ...
- spark streaming的应用
今天我们讲spark streaming的应用,这个是实时处理的,类似于Storm以及Flink相关的知识点, 说来也巧,今天的自己也去听了关于Flink的相关的讲座,可惜自己没有听得特别清楚,好像是 ...
- [bzoj1552][Cerc2007]robotic sort&&[bzoj3506][Cqoi2014]排序机械臂
非常垃圾的一道平衡树,结果被日了一天.很难受嗷嗷嗷 首先不得不说网上的题解让我这个本来就不熟悉平衡树的彩笔很难受——并不好理解. 还好Sinogi大佬非常的神,一眼就切掉了,而且用更加美妙的解法. 题 ...
- toolbar menu 字体颜色和大小
Toolbar菜单中menu当中我们大多数都使用图片来按钮,可是有些时候我们也会直接使用文字,文字的颜色如何修改呢. 其实很简单,我们只要修改styles.xml文件中,添加一句 <item n ...
- HTTPClient和HttpURLConnection实例对比
HttpURLConnection是java的标准类,什么都没封装. HTTPClient是个开源框架,封装了访问http的请求头,参数,内容体,响应等等. 简单来说,HTTPClient就是一个增强 ...