What is the best way to wait for multiple asynchronous callback functions to finish in Java before continuing. Specifically I\'m using GWT with AsyncCallback, but I think this i
I did something similar to @Sasquatch, but instead making use of a "CallbackCounter" object:
public class CallbackCounter {
private int outstanding;
private final Callback callback;
private final String message;
public CallbackCounter(int outstanding, Callback callback, String callbackMessage) {
this.outstanding = outstanding;
this.callback = callback;
this.message = callbackMessage;
}
public void count() {
if (--outstanding <= 0) {
callback.onSuccess(message);
}
}
}
Then in my callback I just call:
counter.count();