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);
}