httpclient 复用
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
liukang 2025-03-04 23:27:36 +08:00
parent ae05f59e73
commit 5702612323

View File

@ -303,9 +303,9 @@ public class RyTask {
Thread.sleep(start - now - perform.getDelayTime());
log.info("抢票开始了");
for (MyReq r : req) {
log.info("【用户】:" + r.getUser());
// 发起异步请求但不等待结果
CompletableFuture<HttpResponse<String>> future2 = client.sendAsync(r.getRequest(), HttpResponse.BodyHandlers.ofString());
log.info("【用户】:" + r.getUser());
future2.thenAccept(response -> {
// 处理响应例如记录日志
log.info("Response received: " + response.statusCode());
@ -315,6 +315,7 @@ public class RyTask {
ex.printStackTrace();
return null;
});
log.info("测试");
}