Skip to content

Instantly share code, notes, and snippets.

@hanksudo
Created March 11, 2013 07:27
Show Gist options
  • Save hanksudo/5132524 to your computer and use it in GitHub Desktop.
Save hanksudo/5132524 to your computer and use it in GitHub Desktop.
Python: Threading Example
#!/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