标签:结果 print tar ... read [] get run %s
1.线程启动def run(n):
print(‘%s in thread...‘%n)
t=threading.Thread(target=run,args=(n,))
t.start
#线程等待
t.join
2.多线程同时启动并等待执行结果
def run(n):
print(‘%s in thread...‘%n)
t_res=[]
for i in range(10)
t=threading.Thread(target=run,args=(n,))
t.start
t_res.append(t)
for t in t_res:
#线程等待
t.join
3.守护线程
for i in range(10)
t=threading.Thread(target=run,args=(n,))
t.setDaemon(True)
t.start
4.队列queue,使程序解耦,提高效率
标签:结果 print tar ... read [] get run %s
原文地址:http://blog.51cto.com/13803166/2140024