1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| print('主线程执行代码')
from threading import Thread from time import sleep
def threadFunc(arg1,arg2): print('子线程 开始') print(f'线程函数参数是:{arg1}, {arg2}') sleep(5) print('子线程 结束')
thread = Thread( target=threadFunc,
args=('参数1', '参数2') )
thread.start()
thread.join() print('主线程结束')
|