is +=1 thread safe
Alexander Schmolck
a.schmolck at gmail.com
Sun May 4 09:00:59 EDT 2008
Gary Herron <gherron at islandtraining.com> writes:
> But... It's not!
>
> A simple test shows that. I've attached a tiny test program that shows this
> extremely clearly. Please run it and watch it fail.
In [7]: run ~/tmp/t.py
final count: 2000000
should be: 2000000
(I took the liberty to correct your test to actually do what I said, namely
use a numpy.array; just replace ``count = 0`` with ``import numpy; count =
numpy.array(0)``).
'as
p.s. please don't send me copies to on-list replies, at least not without
explicitly mentioning the fact -- I've got better things to do then guessing
whether something was meant to be off-list or not.
More information about the Python-list
mailing list