Created
September 4, 2018 21:58
-
-
Save binaryroot/d304ad9b11387c1942f309fd63a16388 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
launch(context = UI) { | |
val result = async { loadString() }.await() | |
Log.d("TAG", | |
"Post execution thread:"+Thread.currentThread().name) | |
textView.text = result | |
} | |
} | |
private suspend fun loadString() : String { | |
Log.d("TAG", "Execution thread: "+Thread.currentThread().name) | |
delay(1000L) | |
return "Some loaded string..." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment