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 ...
随机推荐
- linux-shell——01
没有什么好的标题,只是一些随笔.我用的是linux虚拟机,red hat 7 一:nat模式使得虚拟机可以访问外网,但是这种模式下只可以访问外网,但外面的不能访问里面 首先将虚拟机的网络连接改为nat ...
- B1005 继续(3n+1)猜想 (25分)
B1005 继续(3n+1)猜想 (25分) 卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程 ...
- python开发基础之字符编码、文件处理和函数基础
字符编码 为什么要有字符编码? 字符编码是为了让计算机能识别我们人写的字符,因为计算机只认识高低电平,也就是二进制数"0","1". 一个文件用什么编码方式存储 ...
- Git-历史穿梭
图形工具:gitk gitk是最早实现的一个图形化的Git版本库浏览器软件,基于tcl/tk实现,因此gitk非常简洁,本身就是一个1万多行的tcl脚本写成的.gitk的代码已经和Git的代码放在同一 ...
- Diycode开源项目 如何解决InputMethodManager造成的内存泄漏问题
1.内存泄漏的状况及原因 1.1.利用LeakCanary查看内存泄漏的状况 1.2.内存泄漏怎么产生的呢? InputMethodManager.mServicedView持有一个最后聚焦View的 ...
- 剑指offer题目练习一
看见了一道二维数组找数的题,已排好序的数组(从左至右从上到下,都是由小变大的)让找数,瞬间就出思路了,并没有必要去看他的解释,两次二分就搞定了. #include<cstdio> #inc ...
- 获取<考试>博文密码!o(*≧▽≦)ツ
就是CJ高二组通用的密码 如果你想知道,请联系QQ,3057244225,或者直接面对面问博主(...) 是我们的内部材料,原创题目是不能外传的.请谅解. 当然如果是原题的话我们是不会上锁的啦
- 《Cracking the Coding Interview》——第9章:递归和动态规划——题目3
2014-03-20 03:01 题目:给定一个已按升序排序的数组,找出是否有A[i] = i的情况出现. 解法1:如果元素不重复,是可以严格二分查找的. 代码: // 9.3 Given a uni ...
- 珍藏版 Python 开发工程师面试试题
珍藏版 Python 开发工程师面试试题 说明:不拿到几家公司的offer,那就是卑鄙的浪费 一.Python_基础语法 1.可变与不可变类型: 2.浅拷贝与深拷贝的实现方式.区别:deepcopy如 ...
- python学习总结---文件操作
# 文件操作 ### 目录管理(os) - 示例 ```python # 执行系统命令 # 清屏 # os.system('cls') # 调出计算器 # os.system('calc') # 查看 ...