Simple use and comparison of c # threads, thread pools, and parallel operations

Source: Internet
Author: User

Refer:

Http://msdn.microsoft.com/zh-cn/library/system.threading.threadpool (VS.80). aspx

Http://www.codeproject.com/KB/threads/threadtests.aspx

Http://www.codeproject.com/KB/threads/smartthreadpool.aspx

Http://blog.zhaojie.me/2009/07/thread-pool-1-the-goal-and-the-clr-thread-pool.html)

Jeffrey Richter <CLR via C #> 3rd Edition

 

First, let's take a look at the Main code of the Main method of the console application:

001 static bool done = false ; 002 static decimal count2 = 0; 003 static int threadDone = 0; // Indicates the number of threads enabled? 004 static System.Timers.Timer timer = new System.Timers.Timer(1000); 005 006 static decimal [] threadPoolCounters = new decimal [10]; 007 static Thread[] threads = new Thread[10]; 008 static System.Timers.Timer[] threadTimers = new System.Timers.Timer[10]; 009 010 static void Main( string [] args) 011 { 012      timer.Stop(); 013      /* When AutoReset is set to false, Timer only triggers an Elapsed event after the first Interval. 014       To keep the Elapsed events triggered at Interval intervals, set AutoReset to true. */ 015      timer.AutoReset = false ; 016      timer.Elapsed += new ElapsedEventHandler(OnTimerEvent); // Trigger the event when timer. Start () 017      decimal total = 0; 018 019      // raw test 020      decimal count1 = SingleThreadTest(); // A single thread to the end 021      Console.WriteLine( "Single thread count = "
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.