import multiprocessingimport osimport timenums = [11, 22, 33]numTest = 10def test():nums.append(44)# global numTestnumTest = 100print("在进程中1中nums=%s" % str(nums))print("在进程中1中nums=%d" % numTest)time.sleep(3)def test2():print("在进程中2中nums=%s" % str(nums))print("在进程中1中nums=%d" % numTest)def main():print("----in 主进程 pid=%d---父进程pid=%d----" % (os.getpid(), os.getppid()))p = multiprocessing.Process(target=test)p.start()# time.sleep(1)p.join()p2 = multiprocessing.Process(target=test2)p2.start()if __name__ == "__main__":main()
1500字范文,内容丰富有趣,写作好帮手!