The coroutine context
The execution of a coroutine always happens inside a context. This context is a group of elements that will allow us to define how the coroutine will be executed and how it should behave. Let's start by talking about some of the contexts that we have already seen.
Note
Each of the items in the context can be considered a context with a single element, that is, a context with a single behavior defined. As explained, a context can actually contain more than one element, so in the next section we will learn how to add and remove elements from a context to create combined behaviors. But for now, we want to talk about them as individual contexts to better explain how they work by themselves.
Dispatcher
Dispatchers determine the thread in which a coroutine will be executed, this includes both where it will be started and where it will be resumed after suspension.
We have talked about dispatchers since the very first chapter. So let's look at a small recap with examples of them...