http://www.cnblogs.com/linhaifeng/articles/7428874.html#_label6

from multiprocessing import Process
import time
import os

class MyProcess(Process):
    def __init__(self, num):
        super(MyProcess, self).__init__()
        self.num = num

    def run(self):
        time.sleep(1)
        print(self.is_alive(), self.num, self.pid)
        time.sleep(1)

if __name__ == "__main__":
    prs = []
    for i in range(5):
        p = MyProcess(i)
        prs.append(i)
        p.start()
'''
True 1 11848
True 3 14252
True 4 5512
True 2 8252
True 0 9892
'''
View Code

相关文章:

  • 2022-12-23
  • 2021-07-30
  • 2021-06-25
  • 2022-03-04
  • 2022-01-14
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案