Last active
May 15, 2017 11:13
-
-
Save mike1026915/092e1d775cf52530ed9e42444c821035 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
n = 0 | |
def add_one(): | |
global n | |
n += 1 | |
def fun(m): | |
threads = [] | |
for i in range(m): | |
t = threading.Thread(target=add_one) | |
threads.append(t) | |
for t in threads: | |
t.start() | |
for t in threads: | |
t.join() | |
return n | |
fun(50000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment