The challenges of atomicity violation can be solved in many ways. The first one tackles the problem in a simple fashion: since we know that the problem can only happen when a state is shared between different threads, we make sure that this never happens.