【发布时间】:2016-09-03 07:06:02
【问题描述】:
我想对这部分脚本做同样的事情,但可能以不同的方式。可能吗?这个脚本等待所有线程都准备好并启动,然后运行 urllib.request 的 while True ......既然我不想复制粘贴这个方法,有没有不同的方法来做到这一点?
import threading, urllib.request
class request(threading.Thread):
def run(self):
while nload:
time.sleep(1)
while True:
urllib.request.urlopen("www.google.it")
nload = 1
for x in range(800):
request().start()
time.sleep(0.003)
print "Thread " + str(x) + " started!"
print "The cycle is running..."
nload = 0
while not nload:
time.sleep(1)
【问题讨论】:
标签: python multithreading python-3.x