add some multiprocess and race condition examples

This commit is contained in:
Mia von Steinkirch 2020-03-04 10:12:53 -08:00
parent 5224dc91ca
commit be98abd3b5
4 changed files with 57 additions and 4 deletions

View file

@ -3,17 +3,16 @@
import threading
x = 0
COUNT = 10000000
def foo():
global x
for i in xrange(COUNT):
for i in range(COUNT):
x += 1
def bar():
global x
for i in xrange(COUNT):
for i in range(COUNT):
x -= 1
t1 = threading.Thread(target=foo)