I recently came across a code snippet that used Runnable with AsyncTask, which I was not familiar with previously.
AsyncTask.execute{
/* Some code to run in Background
* ...
* ...
*/
runOnUiThread{
//run on main thread, just like onPostExecute
}
}
I would like to know how does this compare with following way where we create an AsyncTask class?
class MyAsyncTask : AsyncTask<Unit, Unit, String>() {
override fun doInBackground(vararg params: Unit): String {...}
override fun onPostExecute(result: String) {...}
}
Are there any performance or other downsides of the first method?