Skip to content

Instantly share code, notes, and snippets.

@mike1026915
Last active May 15, 2017 11:13
Show Gist options
  • Save mike1026915/092e1d775cf52530ed9e42444c821035 to your computer and use it in GitHub Desktop.
Save mike1026915/092e1d775cf52530ed9e42444c821035 to your computer and use it in GitHub Desktop.
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