Asynchronous processing in the context of your question is a processing that takes some time to execute and (typically) at the end of that processing the GUI needs to be updated.
You could simply encapsulate this processing and refresh the screen in a method, call this method (from the main thread , otherwise the screen update does not work) and wait for it to run. That would be synchronous processing. But because the processing is time-consuming, the method will take a long time to execute and the screen will lose responsiveness (it will not respond to touch commands or update the graphical interface) because the main thread will be busy executing it. Ideally, the main thread should be restricted to updating the screen and handling input (in this case the touch commands).
For this reason, you do the processing asynchronously: it requests a separate thread (either directly or indirectly through a AsyncTask
or other means) to perform this processing and continues its path normally by running other commands.
When processing terminate the thread , it will put the command that updates the graphical interface (either via Handler
, or runOnUiThread()
, or a callback method of AsyncTask
such as onPostExecute()
, for example).