Part 97 Performance of a multithreaded program


class Program
{
static void Main(string[] args)
{
Stopwatch s = new Stopwatch();
s.Start();
EvenNumbersSum();
OddNumbersSum();
s.Stop();
Console.WriteLine("before using multiple threads"+s.ElapsedMilliseconds);
s = new Stopwatch();
s.Start();
Thread t1 = new Thread(EvenNumbersSum);
Thread t2 = new Thread(OddNumbersSum);
t1.Start();
t2.Start();
t1.Join();
t2.Join();
s.Stop();
Console.WriteLine("after using multiple threads"+s.ElapsedMilliseconds); } public static void EvenNumbersSum()
{
double sum=;
for(int i=;i<=;i++)
{
if(i%==)
{
sum += i;
}
}
Console.WriteLine("sum= "+sum);
} public static void OddNumbersSum()
{
double sum = ;
for (int i = ; i <= ; i++)
{
if (i % == )
{
sum += i;
}
}
Console.WriteLine("sum= " + sum);
}
}

Part 97 Performance of a multithreaded program的更多相关文章
- Part 95 to 96 Deadlock in a multithreaded program
Part 95 Deadlock in a multithreaded program class Program { static void Main(string[] args) { Cons ...
- Design a high performance cache for multi-threaded environment
如何设计一个支持高并发的高性能缓存库 不 考虑并发情况下的缓存的设计大家应该都比较清楚,基本上就是用map/hashmap存储键值,然后用双向链表记录一个LRU来用于缓存的清理.这篇文章 应该是讲得很 ...
- 【转】Multithreaded Python Tutorial with the “Threadworms” Demo
The code for this tutorial can be downloaded here: threadworms.py or from GitHub. This code works wi ...
- [转] Vmware vs Virtualbox vs KVM vs XEN: virtual machines performance comparison
http://www.ilsistemista.net/index.php/virtualization/1-virtual-machines-performance-comparison.html? ...
- Introduction to Multi-Threaded, Multi-Core and Parallel Programming concepts
https://katyscode.wordpress.com/2013/05/17/introduction-to-multi-threaded-multi-core-and-parallel-pr ...
- regardless of how many processors are devoted to a parallelized execution of this program
https://en.wikipedia.org/wiki/Amdah's_law Amdahl's law is often used in parallel computing to predic ...
- Timer.5 - Synchronising handlers in multithreaded programs
This tutorial demonstrates the use of the boost::asio::strand class to synchronise callback handlers ...
- R12: Improving Performance of General Ledger and Journal Import (Doc ID 858725.1 )
In this Document Purpose Scope Details A) Database Init.ora Parameters B) Concurrent Progr ...
- Optimizing Item Import Performance in Oracle Product Hub/Inventory
APPLIES TO: Oracle Product Hub - Version 12.1.1 to 12.1.1 [Release 12.1] Oracle Inventory Management ...
随机推荐
- SAE/ISO standards for Automotive
On-Board Diagnostics J1962 Diagnostic Connector Equivalent to ISO/DIS 15031-3: December 14, 2001J201 ...
- C++进制转换(十进制转二进制、八进制、随意进制)
十进制转二进制: //十进制转二进制 #include<iostream> using namespace std; void printbinary(const unsigned int ...
- android 系统定制的小技巧(网络收集)
1开机图片: android-logo-mask.png android-logo-shine.png 这两个图片一个在上一个在下 ./out/target/common/obj/JAVA_LIBRA ...
- 构建移动Web应用程序的技术堆栈
编写web应用程序时,有很多的技术决策.笔者最近回来编写现代Web应用程序,并希望总结一些曾经在开发周期过程中做了记录零散的想法.这篇文章是关于一套对笔者最近开发的项目有帮助的框架.笔者重温了一些最重 ...
- TP复习10
i * { padding:0; margin:0; } 居中 ## ThinkPHP 3.1.2 模板中的变量#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课 ...
- linux查看CPU性能及工作状态的指令
http://www.aikaiyuan.com/9347.html http://blog.csdn.net/jk110333/article/details/8683478 http://www. ...
- js与C#之间相互调用的一些方法
1.获得aspx客户端请求地址: <a src= 'http://<%=Request.Url.Host %><%= ResolveUrl("../PayCenter ...
- iOS本机生成证书请求文件流程
第一步:苹果机上打开“Finder”,选择“应用程序”,双击打开“实用工具” 第二步:在“实用工具”中,选“择钥匙串访问”,双击打开 第三步: “钥匙串访问”打开,看到如下页面 第四步:选择菜单中“钥 ...
- socket通信简介
转:http://blog.csdn.net/xiaoweige207/article/details/6211577 “一切皆Socket!” 话虽些许夸张,但是事实也是,现在的网络编程几乎都是用的 ...
- 数据结构【三】:简单优先队列PriorityQueue
在数据结构[二]:简单阻塞队列BlockingQueue的基础上添加权限属性:priority,并控制enqueue时根据priority排序插入. 1.定义priority取值范围0~9 2.deq ...