看到了一篇文章,是关于发送http请求时,响应时间过长的问题的解决。
侵删
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>
/**
* 连接池基类
*
*/
public class BaseHttpClientTest {
protected static final int REQUEST_COUNT = 5;
protected static final String SEPERATOR = " ";
protected static final AtomicInteger NOW_COUNT = new AtomicInteger(0);
protected static final StringBuilder EVERY_REQ_COST = new StringBuilder(200);
/**
* 获取待运行的线程
*/
protected List<Thread> getRunThreads(Runnable runnable) {
List<Thread> tList = new ArrayList<Thread>(REQUEST_COUNT);
for (int i = 0; i < REQUEST_COUNT; i++) {
tList.add(new Thread(runnable));