# __author: "ZXYang"
# #date: 2020/5/18
from multiprocessing import Process
import time
class MyProcess(Process):
def __init__(self, name):
super(MyProcess, self).__init__()
self.name = name
def run(self):
time.sleep(1)
print(‘11‘, self.name, time.ctime())
if __name__ == ‘__main__‘:
p_list = []
for i in range(10):
p = MyProcess(‘li‘)
p.start()
p_list.append(p)
for p in p_list:
p.join()
print(‘end ‘, time.ctime())
# from multiprocessing import Process
# import time
#
#
# class MyProcess(Process):
#
# def __init__(self, name):
# super(MyProcess, self).__init__()
# self.name = name
#
# def run(self):
# time.sleep(1)
# print(‘self‘, self.name, time.ctime())
#
#
# if __name__ == ‘__main__‘:
# ps = []
# for i in range(10):
# p = MyProcess(‘li‘)
# ps.append(p)
# p.start()
#
# for p in ps:
# p.join()
#
# print(‘end‘, time.ctime())
原文:https://www.cnblogs.com/zxy01/p/14165738.html