python(threading 线程模块 循环多线程执行)

# Author:Sooele

import threading   #线程模块
import time
def run(n):
    print("task",n)
    time.sleep(2)
start_time = time.time()
for i in range(50):
    t = threading.Thread(target=run,args=("t-%s"%i,))
    t.start()
print("cost:",time.time()-start_time)

1
说点什么

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Recent comment authors
  Subscribe  
提醒
匿名
游客
匿名

asdfasdf