Created
August 30, 2012 21:42
-
-
Save ttreitlinger/3541912 to your computer and use it in GitHub Desktop.
Simple python threading example
This file contains 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
# 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