Ho do you perform asynchronous tasks and notify about their finishing?
I see the next approaches(they are related, but…) for doing it:
- AsynchTask (SwingWorkerTask) where there are the such methods like
onPre() and onPost() with dispatching data to the UI thread - Callbacks/Delegates/Notifications(Notification Center)
- Executor, Callable, Future (maybe)
What is the better choice for writing for example a mobile Rest client?
What technique do you use in your apps?
I usually use Guava ListenableFuture for such tasks. It simplifies almost every concurrent task I need because I don’t have to worry about many things in concurrency.
Also, as explained in the link: