I need to convert a sync method like next:
method (String, String, Object)
to an async method.
The main problem is that we work with Java 1.4 and I can't use Executor, Future, ...
Any ideas?
I need to convert a sync method like next:
method (String, String, Object)
to an async method.
The main problem is that we work with Java 1.4 and I can't use Executor, Future, ...
Any ideas?
Copyright © 2021 Jogjafile Inc.
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
Callbackis something likeIt's preferable to use generic types for the
Callbackresult (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 useObjectand cast or have differentCallbackinterfaces for different returns. Compare with any of the*Listenerinterfaces in Swing/AWT.