Implement runOnUiThread function.