I have a asynchronous web service using axis2 which I call two different times using the same CallBack Hanlder as follows :
stub.startGetData("Foo",callbackhandler)
stub.startGetData("bar",callbackhanlder)
ServiceCallBackhandler callbackhandler = new ServiceCallBackhandler() { .....};
//ServiceCallBackhanlder and stub are generated from a WSDL file
Synchronized(callbackhandler){ callbackhandler.wait()}
//remaining code to be executed
............
...........
The problem in this case is that the “remaining code” is executed once the call returns back after the stub.startGetData("Foo",callbackhandler). I want the callback to wait until it has also finished processing the stub.startGetData("boo",callbackhandler) statement and then execute the remaining code. Is there a way to do it without using two different callbackhanlders, since the processing for both the return values is the same. Thanks.
I think you want something like this…
See also java.util.concurrent.Semaphore, but I think CountDownLatch is what you need from what you have described.