Skip to content

Instantly share code, notes, and snippets.

@ttreitlinger
Created August 30, 2012 21:42
Show Gist options
  • Save ttreitlinger/3541912 to your computer and use it in GitHub Desktop.
Save ttreitlinger/3541912 to your computer and use it in GitHub Desktop.
Simple python threading example
# from: http://www.ibm.com/developerworks/aix/library/au-threadingpython/
import threading, datetime
class ThreadClass(threading.Thread):
def run(self):
now = datetime.datetime.now()
# self.getName() returns the thread's identifier, e.g. "Thread-1"
print "%s says hello at time %s" % (self.getName(), now)
for i in range(2):
t = ThreadClass()
t.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment