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 ...
随机推荐
- WM_QUIT,WM_CLOSE,WM_DESTROY 消息出现顺序及调用方式
http://bbs.ednchina.com/BLOG_ARTICLE_3005455.HTM VC中WM_CLOSE.WM_DESTROY.WM_QUIT消息出现顺序及调用方式 wxleasyla ...
- JSON的解析
一:JSON字符串转换为JSON对象 JSON 最常见的用法之一,是从 web 服务器上读取 JSON 数据(作为文件或作为 HttpRequest),将 JSON 数据转换为 JavaScript ...
- linux 源码编译(转)
源代码的用处无非是以下两点;1、软件根据用户的需要加以定制;2、二次开发;注:要根据软件的许可证书约定为准,开发者许可二次开发才行;1、源码包的打包格式;源代码一般以file.tar.gz file. ...
- UVA 10025 (13.08.06)
The ? 1 ? 2 ? ... ? n = k problem Theproblem Given the following formula, one can set operators '+ ...
- SQL自增长的数据插入
--子增长的插入 /*创建表*/ create table teacher ( id int identity(1,1) primary key not null, name varchar(20) ...
- html页面head区域的编码书写规范
今天我们简单的介绍一下head区域主要放置了内容.这里就不强调css和javascript了,这两者是大家所熟知的. head区一般必须加入的标识有: 公司版权注释 <!--- the site ...
- JavaScript Design Patterns: Mediator
The Mediator Design Pattern The Mediator is a behavioral design pattern in which objects, instead of ...
- 字典树(Trie)的java实现
一.定义 字典树又称单词查找树,Trie树,是一种树形结构,是一种哈希树的变种.典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计.它的优点是:利用 ...
- 终端I/O之特殊输入字符
POSIX.1定义了11个在输入时作特殊处理的字符.实现定义了另外一些特殊字符.表18-6摘要列出了这些特殊字符. 表18-6 终端特殊输入字符 在POSIX.1的11个特殊字符中,可将其中9个更改为 ...
- 慎用preg_replace危险的/e修饰符(一句话后门常用)
要确保 replacement 构成一个合法的 PHP 代码字符串,否则 PHP 会在报告在包含 preg_replace() 的行中出现语法解析错误 preg_replace函数原型: mi ...