我正在向某些服务器并行发送请求,但它们的响应不会同时出现。我必须在 html 页面上显示响应。一种方法是等待所有响应,当所有响应到达时,显示它们。我想要做的是尽快显示响应,而不是等待其他响应。粗略的算法如下所示:
while(all the responses don't come or timeout occurs)
waitForResponse();
if(responseArrived==true){
//put it on html page
}
}
我怎样才能在java中做到这一点?