赞
踩
import threading
def run_thread1():
while True:
print(“1”)
def run_thread2():
while True:
print(“2”)
t1 = threading.Thread(target=run_thread1)
t2 = threading.Thread(target=run_thread2)
t1.start()
t2.start()
t1.join()
t2.join()
继承Thread类,并重写它的run()方法,但是会出现只运行前一个线程代码。
1
1
2
2
1
1
1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。