# coding: utf-8
import multiprocessing
import time
import os
class Count(object):
def __init__(self, list):
self.a = list[0]
self.b = list[1]
def run(self):
if self.a >= 50:
time.sleep(3)
print(self.a,self.b)
else:
time.sleep(2)
print("{}<50".format(self.a),self.b,os.getpid())
pool = multiprocessing.Pool(5)
list = [[35, 1], [67, 2], [45, 1], [77, 2], [55, 2]]
t1 = time.time()
for i in list:
pool.apply_async(func=Count(i).run)
pool.close()
pool.join()
t2 = time.time()
print(t2-t1)
方法没有输出, 大佬们帮看下