Skip to content

Instantly share code, notes, and snippets.

@tochiz
Created December 10, 2011 12:51
Show Gist options
  • Save tochiz/1455094 to your computer and use it in GitHub Desktop.
Save tochiz/1455094 to your computer and use it in GitHub Desktop.
test for thread.
import threading
import time
i = 0
class test(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.daemon = True
def run(self):
global i
for n in range(1000):
i += 1
if __name__ == '__main__':
for n in range(100):
thr = test()
thr.start()
time.sleep(10)
print str(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment