import time
from threading import Thread
import threading
aa = time.time()
def look_thred(name):
for i in range(5):
time.sleep(0.5)
print(‘线程{}运行’.format(name))
t1= Thread(target=look_thred,args=(‘1’,))
t2 = Thread(target=look_thred,args=(‘2’,))
t1.start()
t2.start()
t1.join()
t2.join()
进程
import time
from multiprocessing import Process
def look_ss(name):
for i in range(5):
time.sleep(0.5)
print(‘进程{}运行’.format(name))
if name==“main”:
t1 = Process(target=look_ss,args=(‘1’))
t2 = Process(target=look_ss,args=(‘2’))
t1.start()
t2.start()
t1.join()
t2.join()