Method 2: Shared Directory Plus Lock
In this method, you use a shared directory as before but add a lock so people aren't editing at the same time. (A lock ensures exclusive access to a resource; when someone has the lock, nobody else is allowed to use the resource.)
The lock may be virtual (such as renaming a file), or it can be a physical object (such as a stuffed animal held while the code is locked).
Each pair uses this approach:
Wait until the lock is free.
Back up the system.
This strategy has these effects:
Pairs no longer interfere with each other.
The team no longer works in parallel (trading speed for safety).
If all changes are successful, the mainline is in a good state after each release of the lock.
Changes can be transactional; if a set of changes is unsatisfactory, the pair can restore a previous version (abandoning the unwanted changes).