"Pro. Net 4 Parallel Programming in C #" notes

Source: Internet
Author: User
Tags mutex semaphore
"Pro. Net 4 Parallel Programming in C #" notes

$ periodic scheduled task with

CancellationToken.WaitHandle.WaitOne (TimeSpan)

Feature: If a task is cancel,waitone, it will return immediately.

$ synchronized Meta-select scenario solution serial access Border Zone lock keyword or System.Threading.Monitor or System.Threading.SpinLock increase or decrease value System.Threading.Mutex Synchronous System.Threading.Mutex multiple locks across processes synchronous Threading.WaitHandle.WaitAll () synchronization of all method declarations in a class ([synchronization]) (very heavy) allows multiple readers Read and Write lock

The synchronization element describes the abbreviated form of the lock System.Threading.Monitor, and the heavyweight System.Threading.Barrier sets the signal quantity in advance and continues execution after sufficient semaphore. Automatic reset System.Threading.CountdownEvent similar to barrier, but requires active reset System.Threading.ManualResetEventSlim similar to Countdownevent, But without setting the semaphore number, once set, all waiting threads are freed System.Threading.AutoResetEvent like ManualResetEventSlim, but automatically reset, each time set releases only one waiting thread, Cannot use CancellationToken to wait, does not guarantee which thread is released System.Threading.SemaphoreSlim resembles AutoResetEvent, also does not guarantee which thread is released, However, you can specify the number of threads to release per set, and you can wait with CancellationToken

$ taskscheduler is used to specify which thread executes the task and the number and order of concurrent tasks

The use of thread local Storage (tls,parallel.for) reduces access to competing data and improves performance by accessing only at the end of each branch path.

$ when the operation is simple, you can reduce the overhead of calling a delegate (delegate) by specifying the block mode (chunking partitioner) of the data.

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.