1. 作用
多點干绘证, 干多點
2. 操作
# 多線程
# threading
import time, threading
def loop():
print('thread {} is running...'
.format(threading.current_thread().name))
n = 0
while n < 5:
n = n + 1
print('thread {} >>> {}'
.format(threading.current_thread().name, n))
time.sleep(1)
print('thread {} ended...'
.format(threading.current_thread().name))
print('thread {} is running...'
.format(threading.current_thread().name))
t = threading.Thread(target=loop, name='LoopThread')
t.start()
t.join()
print('tread {} ended...'
.format(threading.current_thread().name))
# threading 類似進(jìn)程,Tread也類似Process