💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
``` public class HttpClientPool { public static void main(String[] args) { PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); cm.setMaxTotal(100);//最大连接数 cm.setDefaultMaxPerRoute(10);//设置每个主机的最大连接数 doGet(cm); doGet(cm); } private static void doGet(PoolingHttpClientConnectionManager cm){ CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build(); HttpGet httpGet = new HttpGet("http://www.baidu.com"); CloseableHttpResponse response = null; try { response = httpClient.execute(httpGet); if (response.getStatusLine().getStatusCode() == 200){ String content = EntityUtils.toString(response.getEntity(), "utf8"); System.out.println(content); } } catch (IOException e) { e.printStackTrace(); }finally { try { response.close(); }catch (Exception e){ e.printStackTrace(); } } } } ```