開啟進程的另一種方法
__init__方法解析
https://www.cnblogs.com/tp1226/p/8453854.html
class MyProcess(Process): # 定義一個類,繼承Process這個類
def __init__(self,a,b,c): # __init__配置模塊的初始化操作
self.a = a
self.b = b
self.c = c
super().__init__()
def run(self): # 重寫run方法,實現多進程的程序代碼
print(os.getppod(),os.getpid())
if __name__ =='__main__':
for i in range(10):# 多次開啟子進程
p = MyProcess(a,b,c)
p.start()
print(p.pid)
print(p.name)
print(p.ident) # 它和pid是一回事
p.terminate() # 強制結束一個子進程
print(p.is_alive) # 查看進程是否還活着