Truth series ~ The "Lock" in the first program"

Source: Internet
Author: User

Back to directory

A shared lock is a lock created by a non-Update (read) operation. Other users can read data concurrently, but no transaction can obtain the exclusive lock on the data until all the shared locks are released. A shared lock (S lock) is also called A read lock. If transaction T adds a s lock to Data Object A, transaction T can only read A and cannot modify A. Other transactions can only apply S locks to transaction, instead, the X lock cannot be applied until T releases the S lock on. This ensures that other transactions can read A, but cannot modify A before T releases the S lock on. Differences between exclusive locks and shared locks 1. Shared locks (S locks): If transaction T adds A shared lock to data a, other transactions can only add A shared lock to A, but cannot apply exclusive locks. Transactions authorized to share locks can only read data and cannot modify data. Exclusive lock (X lock): If transaction T adds an exclusive lock to data a, other transactions cannot block aplus any type. Transactions authorized to exclusive locks can read and modify data. 2. Shared locks can be found in Windows.

3. Other users can read and query data concurrently. But it cannot be modified, added, or deleted. Resource Sharing.

Exclusive lock)

 

EXclusive locks are also called write locks (eXclusive locks). If transaction T adds an X lock to Data Object A, only T can read and modify, no other transactions can apply any type of lock to auntil T releases the lock on. It prevents any other transaction from getting the lock on the resource until the original lock on the resource is released at the end of the transaction. The exclusive lock is always applied during UPDATE operations (INSERT, UPDATE, or DELETE. The difference from the shared lock: the shared lock is also called the Share lock (abbreviated as the S lock). If the transaction T adds the S lock to the Data Object a, other transactions can only apply the S lock to, instead, the X lock cannot be applied until T releases the S lock on. Exclusive lock in C #
TheResource = ReaderWriterLock readerWriterLock = (I =; I <; I ++ readerWriterLock. AcquireReaderLock (Main (Thread tr0 = Thread (

Back to directory

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.