多线程实例 import threading import time def eat(): eatTime = time.time() for i in range(30): print('count = {}'.format(count)) time.sleep(1) print 'eat something in {}'.format(eatTime) return eatTime def playGame(): playTime = time.time() for i in range(3…
今天抽时间又学了一下python的多线程,理解的又多了一些,为了利于理解,写了一段很简单的代码,如下: import threading from time import sleep def task1(): #线程函数1 for i in range(0, 9): print("i am thread one !!") def task2(name): #线程函数2 print('hello {0} {1}'.format(name, 'weiyang')) sleep(1) t1…