1. 程式人生 > >python自帶執行緒池

python自帶執行緒池

1.  注意:  導包是:

    from multiprocessing.pool import ThreadPool  #執行緒池不在thrading中

2.  程式碼:

  from mutiprocessing.pool import ThreadPool

  def func(*args,**kwargs):

    print(args,kwargs)

  pool = ThreadPool(4)

  pool.apply_async(func,args = (1,2),kwds = {"name":'A'})

  pool.close()

  pool.join()

 

圖例: