mirror of
https://github.com/autistic-symposium/web3-starter-py.git
synced 2025-05-18 06:30:23 -04:00
add some multiprocess and race condition examples
This commit is contained in:
parent
5224dc91ca
commit
be98abd3b5
4 changed files with 57 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue