多线程与多进程衔接

  • A+
所属分类:Python基础 默认

from concurrent.futures import ThreadPoolExecutor,ProcessPoolExecutor,as_completed

多线程

with ThreadPoolExecutor(3) as executor:

    all_task = [executor.submit(fib, (num)) for num in range(25,40)]

    for future in as_completed(all_task):

        data = future.result()

        print(data)

多进程

with ProcessPoolExecutor(3) as executor:

all_task = [executor.submit(fib, (num)) for num in range(25,40)]

for future in as_completed(all_task):

data = future.result()

print(data)

  • 微信
  • 等你哟
  • weinxin
  • 微信公众号
  • mac软件资源等你来拿
  • weinxin
小羊同学

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: