Skip to content

Instantly share code, notes, and snippets.

@neriberto
Created April 24, 2014 13:48
Show Gist options
  • Save neriberto/11255277 to your computer and use it in GitHub Desktop.
Save neriberto/11255277 to your computer and use it in GitHub Desktop.
One attempt to work with multi thread in python
import threading
from time import sleep
finish = False
def thread1():
print "entrando thread1"
global finish
sleep(10)
print "acabou thread1"
finish = True
def thread2():
print "entrando thread2"
print "acabou thread2"
t1 = threading.Thread(target=thread1, args=[])
t2 = threading.Thread(target=thread2, args=[])
t1.start()
t2.start()
while not finish:
pass
print "acabou"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment