目录

一个关于python多线程的简单使用

目录
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
def doGet(url, name):
    s = requests.session()
    s.get(url)

thread_num = 10
threads=[]
for i in xrange(num):
    url = "xxx"
    t = threading.Thread(target=doGet, args=(url, i))
    threads.append(t)

for t in threads:
    t.start()
for t in threads:
    t.join()  #需要注意join函数的功能,主要是阻塞主线程