多进程

作者: 裴general | 来源:发表于2018-10-07 22:55 被阅读0次
    from multiprocessing import Process
    import time
     
     
    class MyProcess(Process):
        def __init__(self, loop):
            Process.__init__(self)
            self.loop = loop
     
        def run(self):
            for count in range(self.loop):
                time.sleep(1)
                print('Pid: ' + str(self.pid) + ' LoopCount: ' + str(count))
     
     
    if __name__ == '__main__':
        for i in range(2, 5):
            p = MyProcess(i)
            p.start()
    
    

    相关文章

      网友评论

          本文标题:多进程

          本文链接:https://www.haomeiwen.com/subject/sorpgftx.html