欢迎光临散文网 会员登陆 & 注册

马老师Java零基础从入门到就业

2022-10-25 22:15 作者:呵呵呵呵呵sp  | 我要投稿

from multiprocessing import Processimport timeclass SumProcess(Process):    def __init__(self, n, e=None):        super().__init__()  # 调用父类的初始化方法: 一定写,因类进程的创建由系统,初始化方法由系统调用。        self.n = n        self.e = e    def run(self):        # 当前进程分配资源后,由创建的线程来执行的函数,系统调用的        s = 0        for i in range(1, self.n + 1):            if self.e and i % self.e == 0:                continue            s += i            time.sleep(0.001)            print(self.name, i)        print(self.name, self.n, '以内的所有数据和为', s)

马老师Java零基础从入门到就业的评论 (共 条)

分享到微博请遵守国家法律