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的更多相关文章

  1. Part 95 to 96 Deadlock in a multithreaded program

    Part 95   Deadlock in a multithreaded program class Program { static void Main(string[] args) { Cons ...

  2. Design a high performance cache for multi-threaded environment

    如何设计一个支持高并发的高性能缓存库 不 考虑并发情况下的缓存的设计大家应该都比较清楚,基本上就是用map/hashmap存储键值,然后用双向链表记录一个LRU来用于缓存的清理.这篇文章 应该是讲得很 ...

  3. 【转】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 ...

  4. [转] Vmware vs Virtualbox vs KVM vs XEN: virtual machines performance comparison

    http://www.ilsistemista.net/index.php/virtualization/1-virtual-machines-performance-comparison.html? ...

  5. 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 ...

  6. 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 ...

  7. Timer.5 - Synchronising handlers in multithreaded programs

    This tutorial demonstrates the use of the boost::asio::strand class to synchronise callback handlers ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Delphi Data Type to C# Data Type

    Delphi DataType C# datatype ansistring string boolean bool byte byte char char comp double currency ...

  2. Flexigrid在IE下不显示数据的处理

    文章总结自我的论坛提问: http://bbs.csdn.net/topics/390498434?page=1#post-394918028 解决方法: 网上的答案经我验证都是不靠谱的,以后大家就知 ...

  3. map的实现

    1.map的实现是使用平衡树,AVL树或者红黑树. 2.在无序的情况下,查找为常数时间.有序的时候,查找为对数时间.二叉排序树(BST)就是为了解决这个问题. 3.但是,极端情况下,BST的查找效率退 ...

  4. CSS的魔法和魅力

    其实我最开始学会的语言是HTML,我记得那还是大一的事情.当时我对床的兄弟DR放了一本HTML的书在床上,我因为没事就拿来看看.那本书大概只有50页左右,可是可以说如果没有这本书,今天Maybe我不会 ...

  5. Codeforces Gym 100187D D. Holidays 排列组合

    D. Holidays Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/D ...

  6. ORA-01489: result of string concatenation is too long

    ORA-01489: result of string concatenation is too long Cause: String concatenation result is more tha ...

  7. 腾讯微博java(android)sdk新增微博api详细介绍

    本文主要介绍腾讯微博android sdk中新增微博有关的8个接口,以及使用的示例代码 注意:以下所有的api示例代码都需要先新建QqTSdkService类对象qqTSdkService并初始化,见 ...

  8. Swift 本地推送通知UILocalNotification

    Notification是智能手机应用开发中常用的信息传递机制,它不用消耗更多资源去不停的检查信息状态,可以非常好的节省资源. 在iOS中分为两种通知:本地.远程.本地的UILocalNotifica ...

  9. 关于OpenGL+GLSL深度贴图采样

    作者:Nin+.Lee 邮箱:lilei9110@gmail.com * 本文属原创,转载请注明出处. 在GLSL中,存在着sampler2D和sampler2DShadow两种2D贴图采样器.在对一 ...

  10. [android]fmodex在某些android设备上声音延迟Latency

    // The default on windows in bufferlength = 1024 and numbuffers = 4 hr = g_pFmodSystem->setDSPBuf ...