Contexts and scope
Context and scope are fundamental concepts in the world of Kotlin coroutines and play a crucial role in managing their life cycle and behavior.
A context in Kotlin coroutines is like a container that groups key information about how and where a coroutine will run. This context includes the following:
- Dispatcher: Defines which thread or thread group the coroutine will run on, as follows:
Dispatchers.IOfor I/O operations (such as working with files or network calls).Dispatchers.Mainfor updating the UI.
 - Job: Represents the specific task the coroutine performs. It also allows you to cancel it or monitor its progress.
 - Other attributes: Can include things such as the following:
CoroutineName: A useful identifier to distinguish coroutines.NonCancellable: Indicates that the coroutine should not be cancelled, even if its parent or associated scope is.
 
In addition...