你看到的entity.getcontentlength返回-1了,baidu了?看到类似的这篇文章了--》http://blog.csdn.net/ffm83/article/details/41944921
然后,你信了?就这么的解释了?或者就这么的不拘泥于细节直接换成了
EntityUtils.toString(entity).length(); 了?
你怎么玩我不知道,也可以说达到了目的就ok,不纠结细节有时候也是对的,但是,怀着憧憬,我按照那篇文章试了下,结果,console输出的是(当有一个线程的时候)
use the new method,the content length is:-1
是的,还是,,,,,,-1
但是如果是多个线程(比如我修改为10),结果为:
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:4905
use the new method,the content length is:4905
use the new method,the content length is:4905
use the new method,the content length is:4905
use the new method,the content length is:4905
当然,那篇文章里面对于header的设置是需要的,否则就会是:
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
use the new method,the content length is:-1
所以,这一句:// httpget.setHeader("Accept-Encoding", "identity")
还是不能注释掉的,它的作用还是存在着价值的。那这个地方到底又是哪里有了问题,为何一个线程的时候就是-1呢?
executeservice.execute(work)执行对应的Runnable-》run()方法,应该也是预期的4905(本例子)
看官,如若你知道,请不吝赐教