There are tow locking ways: optimistic and pessimistic locking.
Optimistic locking applies the following case:
there are infrequenct conflicts between concurrrent transactions that mean they are not often trying to read and change the same data at the same time.
Pessimistic locking is suitabe for the case:
The transactions will collide frequently. In pessimistic locking, when a transaction reads the data, it will lock it. At meantime, another transaction cannot change the data until the first one commits its read.