【C/C++開發】多執行緒程式設計中的join函式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#
coding: utf-8
#
測試多執行緒中join的功能
import threading,
time
def doWaiting():
print 'start
waiting1: ' + time.strftime( '%H:%M:%S' ) + "\n"
time.sleep( 3 )
print 'stop
waiting1: ' + time.strftime( '%H:%M:%S' ) + "\n"
def doWaiting1():
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 = doWaiting) thread1.start()
tsk.append(thread1)
thread2 = threading.Thread(target = doWaiting1)
|