在多线程环境下,使用 httpclient.xxx.jar包的 new DefaultHttpClient() ; 构造函数创建的client客户端将会引发以下这个错误:
Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
解决办法:
使用 new DefaultHttpClient(new ThreadSafeClientConnManager()); 构造一个client客户端即可解决该问题