Zeroc Ice 学习笔记--异步调用

 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 asyncResults = new ArrayList<>();
for(int i = 0 ;i<2;i++){
    asyncResults.add(helloWorldPrx.begin_sayHelloWorld());
}
while (!asyncResults.isEmpty()){
    Iterator 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);
}

 

转载于:https://my.oschina.net/cxlt216/blog/748551

你可能感兴趣的:(Zeroc Ice 学习笔记--异步调用)