关于httpclient (java.lang.IllegalStateException)

多线程时使用httpclient-4.1.2.jar包的newDefaultHttpClient()构造客户端报错!

InvaliduseofSingleClientConnManager:connectionstillallocated.Makesuretoreleasetheconnectionbeforeallocatinganotherone.java.lang.IllegalStateException:InvaliduseofSingleClientConnManager:connectionstillallocated.Makesuretoreleasetheconnectionbeforeallocatinganotherone....

解决办法:加上newThreadSafeClientConnManager()即可解决该问题

HttpClient httpclient = new DefaultHttpClient(new ThreadSafeClientConnManager());

相关推荐