首页 > 系统服务 > 详细

类创建进程

时间:2020-12-20 23:17:48      阅读:33      评论:0      收藏:0      [点我收藏+]
# __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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!