Intermediate Topic 20 of 51 Concurrency & Parallelism
Coroutines
Functions that suspend and resume cooperatively.
How it works
Coroutines are functions that suspend and resume cooperatively (yield, await), switching without OS threads at a cost of a function call; Kotlin, Python asyncio, Lua.
Where it is used
Lightweight concurrency.
Common pitfall
They need explicit yield points; long non-yielding code starves peers.
Where it fits in the course
Coroutines is topic 20 of 51 in Concurrency & Parallelism, rated Intermediate. It follows Event-Driven Concurrency. The next topic is Futures and Promises Model.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Concurrency & Parallelism quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Concurrency & Parallelism quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Coroutines?
Functions that suspend and resume cooperatively. It belongs to Concurrency & Parallelism and is an intermediate-level topic.
Where do people use Coroutines?
Lightweight concurrency.
What is the most common mistake with Coroutines?
They need explicit yield points; long non-yielding code starves peers.
What should I learn before this topic?
Start with Event-Driven Concurrency, the topic just before it in Concurrency & Parallelism.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Concurrency & Parallelism quiz.
Is Coroutines hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn Coroutines?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Coroutines?
Event-Driven Concurrency, Futures and Promises Model, Async/Await are closely connected. The full list is in the related topics section of this page.
What should I study after Coroutines?
Continue with Futures and Promises Model, the next topic in Concurrency & Parallelism.
Related topics
- Event-Driven Concurrency (Concurrency & Parallelism)
- Futures and Promises Model (Concurrency & Parallelism)
- Async/Await (Concurrency & Parallelism)
- Green Threads (Concurrency & Parallelism)