How to use multiple threads

前端 未结 5 1695
臣服心动
臣服心动 2021-02-05 11:16

I have this code:

import thread

def print_out(m1, m2):
    print m1
    print m2
    print \"\\n\"

for num in range(0, 10):
    thread.start_new_thread(print_o         


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 12:02

    The other approach is using threading class.

     instance[num]=threading.Thread(target=print_out, args=('a', 'b'))
    
     instance[num].start()
    

提交回复
热议问题