Which fix removes the bug?
import threading
count = 0
def bump():
global count
count += 1
- Guard it with a Lock
- Make count a float
- Use a nested function
- Declare count nonlocal
+= is a read, add and write; two threads can interleave and lose an increment.