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