Solutions for controlling transactions in multithreading or concurrency

Source: Internet
Author: User

1 Preface

There are many ways to control multi-threaded synchronization, such as the addition of synchronous locking mechanism, but this will bring some performance consumption, because to queue mechanism, the previous period of time to see someone else's code has a class (Threadlocal<t> generic Class) caught my attention.

2. Concept Threadlocal

View MSDN Explanation: to provide the thread local storage of data, in fact, it is easy to understand that a variable in multiple threads to implement multiple copies (copy), because the mechanism of multithreading, the variables of each thread are not affected, so do not worry about the variable caused by pollution, each use of the need not worry. Common variables for multiple threads can be implemented during database connection operations or ORM context operations.

Refer to the article: http://blog.csdn.net/sonny543/article/details/51336457

Solutions for controlling transactions in multithreading or concurrency

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.