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)