Like already being mentioned, I would pay a great emphasis on the fact that intertwining your synchronous code, with asynchronous code is a bad and poor approach. The two should be left alone, and should work in their own contexts.
What you are creating is useful, and really very much helpful in the cases where you need some IO operations (such as writing to databases, reading files, downloading from network) etc and that is exactly why
AsyncTask
and other types are provided, but never intertwine the UI with the background threads. Instead, when something is going on in async, perform the rest of the tasks there — you can set events, handlers and
runOnUiThread
calls to update the UI as the task progresses.
One more thing, async tasks should be used for IO intensive operations only, for anything that is CPU bound, consider running it as a service so that it runs anytime in the background and can consume CPU, but not intensively.
Finally, I would recommend that you give the Android developer documentation a read, to learn more about what Android platform has to offer for threading:
Sending Operations to Multiple Threads | Android Developers[
^]
android - how to use runOnUiThread - Stack Overflow[
^]