Python:创建多线程
#coding=utf-8
import threading
import time
class MyThread(threading.Thread):
def __init__(self, name, delay):
threading.Thread.__init__(self)
self.name = name
self.delay = delay
def run(self):
time.sleep(self.delay)
print self.name, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
th1 = MyThread('th1',2)
th2 = MyThread('th2',1)
th1.start()
th2.start()
print 'main done.'