Zeroc Ice 学习笔记 - 异步调用
最编程
2024-07-16 16:00:16
...
【直播预告】程序员逆袭 CEO 分几步?
Zeroc Ice 学习笔记--异步调用
AsyncResult result = helloWorldPrx.begin_sayHelloWorld();
while (true){
System.out.println("is call request sent:"+result.isSent());
if(result.isCompleted()){
System.out.println("call finished,return :"+helloWorldPrx.end_sayHelloWorld(result));
break;
}else {
System.out.println(" wait for finished");
Thread.sleep(1000);
}
}
ArrayList<AsyncResult> asyncResults = new ArrayList<>();
for(int i = 0 ;i<2;i++){
asyncResults.add(helloWorldPrx.begin_sayHelloWorld());
}
while (!asyncResults.isEmpty()){
Iterator<AsyncResult> iterable = asyncResults.iterator();
while (iterable.hasNext()){
AsyncResult asyncResult = iterable.next();
if(asyncResult.isCompleted()){
System.out.println(helloWorldPrx.end_sayHelloWorld(asyncResult));
iterable.remove();
}
}
Thread.sleep(1000);
}
上一篇: java 异步将日志写入文件的实现代码
下一篇: Java 通过时间梯度实现异步回调接口