Broken counter

Cosmin
Cosmin Negruseri
23 august 2012

What's the minimum value this Python code can print:

The fact that the code is in Python doesn't really matter. Basically you're given 5 threads that each increment an integer variable counter exactly 10 times. The variable isn't guarded by any lock. You can assume that reads and writes to the variable are atomic operations. What's the minimum value the counter can have after all threads finished.

Categorii:
remote content