zzzzz404 于 2015.06.09 22:17 提问

5个回答

CodeofWorker   2015.06.09 22:33

CodeofWorker 我又来了，没有正式写，但方案应该是把文件以同一 二进制排序规则进行分割成若干个字节包，再以多线程方式同时下载指定数量的包，若有11个包，每线程分配5，用三个线程去下。。应该是可行的。
2 年多之前 回复
devmiao      2015.06.09 23:22

sxjiangdongqin   2015.06.10 08:10

from time import ctime

def init(self, func, args, name):
self.name = name
self.func = func
self.args = args

``````def run(self):
print 'starting', self.name, 'at:',ctime()
apply(self.func, self.args)
print self.name, 'finished at:', ctime()
``````

def fun1(x):
y = 0
for i in range(x):
y+=1

def fun2(x):
y = 0
for i in range(x):
y+=1

def main():
fun1(10000000)
fun2(10000000)

``````t1 = MyThread(fun1,(10000000,),fun1.__name__)
t1.start()
t2.start()
t1.join()
t2.join()

print 'all done'
``````

if name == '__main__':
main()

``````    import threading
``````

from time import ctime

def init(self, func, args, name):
self.name = name
self.func = func
self.args = args

``````def run(self):
print 'starting', self.name, 'at:',ctime()
apply(self.func, self.args)
print self.name, 'finished at:', ctime()
``````

def fun1(x):
for i in range(x):
fd = open('1','w')
fd.close()

def fun2(x):
y = 0
for i in range(x):
y+=1

def main():
fun1(15000)
fun2(50000000)

``````t1 = MyThread(fun1,(15000,),fun1.__name__)
t1.start()
t2.start()
t1.join()
t2.join()

print 'all done'
``````

if name == '__main__':
main()

lzp_lrp      2015.06.10 09:11

oyljerry      2015.06.09 22:30