Created
March 11, 2013 07:27
-
-
Save hanksudo/5132524 to your computer and use it in GitHub Desktop.
Python: Threading Example
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
""" | |
Threading Example | |
@author: Hank Wang <[email protected]> | |
@version: 20101230 | |
""" | |
import time | |
from threading import Thread | |
def myfunc(i): | |
print("sleeping 10 sec from thread %d" % i) | |
time.sleep(10) | |
print("finished sleeping from thread %d" % i) | |
def main(): | |
for i in range(10): | |
t = Thread(target=myfunc, args=(i,)) | |
time.sleep(1) | |
t.start() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment