C # Database concurrency Solution (General Edition, EF Edition)

Source: Internet
Author: User
Tags ticket

Or the old saying: 10 years Hedong, 10 years hexi, MO bullying year poor! ~_~ dozen wrong words, should be MO bullying Juvenile poor!

Education represents your past, ability represents your present, study represents your future.

Lifelong learning, excellence.

Since the birth of ASP, Microsoft has provided a lot of control concurrency method, before we understand these control concurrency method, we first to briefly introduce the concurrency!

Concurrency: Concurrency occurs when multiple visitors simultaneously access an update operation at the same time or at the same moment!

The processing of concurrency is divided into pessimistic concurrency processing and optimistic concurrency processing.

The so-called pessimistic/optimistic concurrent processing, it can be understood:

Pessimists think: In the process of running the program, concurrency is very easy to drip, so the pessimists put forward their processing mode: When I execute a method, other visitors are not allowed to intervene in this method. ( pessimists often think that something bad is going to happen to them )

Optimists argue that, in the process of running a program, concurrency is infrequent, so optimists present their handling patterns: When I execute a method, allow other visitors to intervene in the method. ( optimists often think that a bad thing doesn't happen to them )

So in the C # language, what are those pessimists?

in C #, such as: Lock, Monitor, interlocked and other methods of locking data, belong to pessimistic concurrency processing category! Once the data is locked, other visitors are not authorized to access it. Interested can be consulted: locks, monitor and lock in C #, and differences

However, there is a common problem with pessimists dealing with concurrency, which is that it can result in very low execution efficiency.

Here: For a simple example:

Ticket system, Xiao Ming to buy tickets to Beijing to Shanghai D110 train, if the use of pessimists to deal with the concurrent mode, then the conductor will D110 the ticket lock, and then make the ticket operation. However, during the D110 train ticket was locked, the conductor went to the toilet, or drank a cup of coffee, the other window conductor is not allowed to make ticket drops! With this approach, China's 1.4 billion people don't have to travel because they can't buy tickets ~_~

Therefore: in

C # Database concurrency Solution (General Edition, EF Edition)

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.