HP Inc. Interview Question

explain how to prevent race condition