Java 8 Apache HttpClient-连接速度慢

Java 8 Apache HttpClient-连接速度慢,java,httpclient,apache-httpclient-4.x,Java,Httpclient,Apache Httpclient 4.x,我有一个Executor服务,它运行的可运行程序如下: public class Rexecutor implements Runnable { @Override public void run() { while(thisUseAmount.intValue() <= amountToGoal) { try { requests(); } catch (Exception

我有一个Executor服务,它运行的可运行程序如下:

public class Rexecutor implements Runnable {

    @Override
    public void run() {
        while(thisUseAmount.intValue() <= amountToGoal) {
            try {
                requests();
            } catch (Exception ex) {
                //blah blah
            }
        }
    }

    private void requests() throws Exception {
        <<HttpRequests (Gets, Posts, Puts) through HttpClient>>
    }

}
公共类Rexecutor实现可运行{
@凌驾
公开募捐{

while(thisUseAmount.intValue()我建议您使用Apache HttpClient,而不是JDK提供的默认值。

经过数小时的搜索,我找到了一个解决方案:

private HttpClientBuilder client = HttpClientBuilder.create().setRetryHandler(new DefaultHttpRequestRetryHandler(Integer.MAX_VALUE, true));

只需添加重试处理程序:)

Ohh抱歉,我当然在使用ApacheHttpClient。我没有提到它,因为我认为只有一个HttpClient:l