from multiprocessing import Process
def task(name):
for i in range(10000):
print(f"{name}:",i)
if __name__ == '__main__':
p = Process(target=task,args=("dfa",))
p.start()
p1 = Process(target=task,args=("d花木成畦手自栽a",))
p1.start()
for i in range(1000):
print("主进程:", i)
#
# class MyProcess(Process):
# def run(self): # 固定的 -> 当线程被执行的时候,被执行的就是run()
# for i in range(1000):
# print("子线程", i)
#
# if __name__ == '__main__':
# p = MyProcess()
# p.start()
# for i in range(1000):
# print("主进程:", i)
标签:__,name,start,Process,print,range,进程
From: https://www.cnblogs.com/Wesuiliye/p/17176929.html