Hassaan
02/05/2024, 1:31 PMclass MainActivity : ComponentActivity() {
private val TAG = "FUN"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {}
GlobalScope.launch(Dispatchers.Main) {
execute()
}
}
private fun execute() {
val parentJob = GlobalScope.launch(Dispatchers.Main) {
Log.d(TAG, "Parent Started")
val childJob = launch() {
Log.d(TAG, "Child Started")
delay(1000)
Log.d(TAG, "Child Ended")
}
delay(3000)
Log.d(TAG, "Parent Ended")
}
}
}
when we run and debug it, produces two different results? This result can also change depends on the no. of breakpoints used and where these breakpoints are used?Hassaan
02/05/2024, 1:34 PM