提问人:Saksham Gupta 提问时间:4/21/2023 更新时间:4/21/2023 访问量:28
线程在 thenAccept 中被阻止,但在 thenAcceptAsync 中工作
Thread gets blocked in thenAccept but works in thenAcceptAsync
问:
我正在使用 Helidon WebClient 进行 API 调用,我遇到了某个用例,我正在粘贴该用例的演示。
var request = webClient.get()
.path("/api/users?page=2")
.request(String.class)
.thenAccept(res -> {
printThreadId("firstreq");
System.out.println(res);
var res2 = webClient.get()
.path("/api/users?page=2")
.request(String.class)
.await();
System.out.println(res2);
cf.complete(null);
});
问题是线程在 res2 调用后被阻塞了无休止的时间。
解决方案是使用 thenAcceptAsync 而不是 thenAccept。但是,我无法理解,为什么会这样?
答: 暂无答案
评论
webClient
thenAccept
webClient
thenAccept
thenAcceptAsync
await()
CompletionStage
request