2018年好博文集合-持續更新
阿新 • • 發佈:2018-12-10
2018年11月27號
2018年11月28號
測試原始碼:
def doWaiting1(): print('start waiting1:' + time.strftime('%H:%M:%S')+ '\n') time.sleep(3) print('stop waiting1:' + time.strftime('%H:%M:%S')+'\n') def doWaiting2(): print('start waiting2:' + time.strftime('%H:%M:%S')+'\n') time.sleep(8) print('stop waiting2:' + time.strftime('%H:%M:%S') + '\n') tsk = [] thread1 =threading.Thread(target = doWaiting1, name = 'thread1') thread1.start() tsk.append(thread1) thread2 =threading.Thread(target = doWaiting2, name = 'thread2') thread2.start() tsk.append(thread2) print ('start join:' + time.strftime('%H:%M:%S') + '\n') for i in tsk: i.join(3) print('end join:' + time.strftime('%H:%M:%S') + '\n')