Learn CS Visual

Update Conflicts and Isolation via Locking

Concurrency control prevents data from becoming inconsistent when multiple transactions try to update the same data at the same time. Without locking, both transactions read the value before either writes, so one update overwrites the other and a decrement gets lost — an update conflict. With locking, the transaction that read first can make the other wait until it finishes, so no update is lost.

Running both transactions with no locking, what is the final value of stock?