About this question

Concurrent Counter Increment

Hard · Code Analysis · Quant Trader interview question · concurrency, race-condition, threads, counter

Two threads are spawned, each executing a function that increments a shared counter variable by one, 1,000,000 times. The counter is initialized to zero. No locks or other synchronization mechanisms are used. After both threads complete, what can you definitively say about the final value of the counter?