Check-Then-Act can fail if another thread changes the state between the check and the act.
In a multithreaded environment, 'Check-Then-Act' can lead to race conditions where the state checked might change before acting on it. For example, if a thread checks if an item is in stock before decrementing it, another thread might purchase it between the check and the act, resulting in overselling. Synchronization or atomic constructs can ensure that the state remains consistent during such operations.
Additional Notes
How can ‘Check-Then-Act’ lead to concurrency problems?