Define a callback interface (if one isn't already available) and make your method take the interface as a parameter. The method will go off and do its work, and when it's finished, it calls the callback.
Example:
int synchronousMethod(int arg0, String arg1) {
int result = doStuff();
return result;
}
It's preferable to use generic types for the Callback result (GWT, for example, uses a generic AsyncCallback<ResultType> that is identical to the interface above), but since generics aren't available in 1.4, you can either use Object and cast or have different Callback interfaces for different returns. Compare with any of the *Listener interfaces in Swing/AWT.
Define a callback interface (if one isn't already available) and make your method take the interface as a parameter. The method will go off and do its work, and when it's finished, it calls the callback.
Example:
becomes
where
Callback
is something likeIt's preferable to use generic types for the
Callback
result (GWT, for example, uses a genericAsyncCallback<ResultType>
that is identical to the interface above), but since generics aren't available in 1.4, you can either useObject
and cast or have differentCallback
interfaces for different returns. Compare with any of the*Listener
interfaces in Swing/AWT.