简单的python线程操作代码

来源:互联网 发布:淘宝平面模特兼职 编辑:程序博客网 时间:2024/04/29 14:14
#coding=utf-8import httplibimport threadingdef jb51():url = "http://www.jb51.net/article/66763.htm"conn = httplib.HTTPConnection("www.jb51.net")conn.request(method="GET",url=url) response = conn.getresponse()res= response.statusprint resthreads=[]for i in range(10):t=threading.Thread(target=jb51,args=())     #把创建的线程加入线程组 threads.append(t)       if __name__ == '__main__':   #启动线程     for i in threads:          i.start()     #keep thread     for i in threads:          i.join()
0 0
原创粉丝点击