1,最简单的线程例子:
2,多线程并发:
1 import time 2 from threading import Thread 3 #多线程并发 4 def func(n): 5 time.sleep(1) 6 print(n) 7 for i in range(10): 8 t = Thread(target=func,args=(i,)) 9 t.start()
运行结果: