Skip to content

Instantly share code, notes, and snippets.

@dongweiming
Last active September 20, 2016 03:00
Show Gist options
  • Save dongweiming/afecc286fa1d73e5c3652776030bbcaa to your computer and use it in GitHub Desktop.
Save dongweiming/afecc286fa1d73e5c3652776030bbcaa to your computer and use it in GitHub Desktop.
test
import threading
count = 0
def incre():
global count
count += 1
def bye():
while 1:
incre()
def hello_there():
while 1:
incre()
def main():
for func in [hello_there, bye]:
t = threading.Thread(target=func)
t.start()
while 1:
print count
main()
import threading
result = [0]
def incre():
global result
result.append(max(result) + 1)
def bye():
while 1:
incre()
def hello_there():
while 1:
incre()
def main():
for func in [hello_there, bye]:
t = threading.Thread(target=func)
t.start()
while 1:
print result
main()
import threading
result = [0]
def incre():
global result
result.extend([max(result) + 1])
def bye():
while 1:
incre()
def hello_there():
while 1:
incre()
def main():
for func in [hello_there, bye]:
t = threading.Thread(target=func)
t.start()
while 1:
print result
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment