Pythonマルチスレッドの使用

インポートスレッド

import threading

def fcn1():
    print('fcn1 start')
    for i in range(5):
        print('fcn1 i={}'.format(i))


def fcn2():
    print('fcn2 start')
    for i in range(5):
        print('fcn2 i={}'.format(i))


thread1 = threading.Thread(target=fcn1)
thread2 = threading.Thread(target=fcn2)

thread1.start()
thread2.start()
thread1.join()        # join函数决定线程开始的顺序
thread2.join()

おすすめ

転載: blog.csdn.net/wxyczhyza/article/details/129119595