package
com.example.gfgcoroutines
import
androidx.appcompat.app.AppCompatActivity
import
android.os.Bundle
import
android.util.Log
import
android.widget.Toast
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
class
MainActivity : AppCompatActivity()
{
val TAG=
"Main Activity"
override fun onCreate(savedInstanceState: Bundle?)
{
super
.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Log.d(TAG,
"Before run-blocking"
)
runBlocking
{
Log.d(TAG,
"just entered into the runBlocking "
)
delay(
5000
)
launch(Dispatchers.IO)
{
delay(3000L)
Log.d(TAG,
"Finished to coroutine 1"
)
}
launch(Dispatchers.IO)
{
delay(3000L)
Log.d(TAG,
"Finished to coroutine 2"
)
}
Log.d(TAG,
"start of the run-blocking"
)
Log.d(TAG,
"End of the runBlocking"
)
}
Log.d(TAG,
"after the run blocking"
)
GlobalScope.launch
{
Log.d(TAG,
"Logging in the globalScope"
)
}
}
}