Skip to content

cooperative multitasking

Cooperative multitasking is a scheduling approach in which each running task keeps control of the CPU until it voluntarily yields, rather than being interrupted by the operating system. Because no task can be forced to pause, the scheduler relies on every task to hand control back on its own, usually at a defined yield point.

Running without interruption between those yield points has real advantages. Shared data cannot change halfway through an operation, so a task needs far less locking to stay correct, and switching between tasks stays cheap because no timer interrupt is involved.

The trade-off is fragility. One uncooperative task breaks the whole model, because a task stuck in a long computation or a blocking call never yields, so it starves the others and can freeze the entire system.

The widget below lets you watch three tasks hand off a single CPU at their yield points, then make one task refuse to yield and see the others starve:

Interactive diagram — enable JavaScript to view.

Early desktop systems such as Windows 3.x and classic Mac OS scheduled programs this way before preemptive multitasking took over. The pattern still underpins asynchronous programming, where an event loop runs one coroutine at a time and each coroutine yields at an await expression so the loop can resume another. Python’s asyncio drives concurrent work on a single thread in exactly this cooperative style.

Async IO in Python: A Complete Walkthrough

Course

Hands-On Python 3 Concurrency With the asyncio Module

Learn how to speed up your Python 3 programs using concurrency and the asyncio module in the standard library. See step-by-step how to leverage concurrency and parallelism in your own programs, all the way to building a complete HTTP downloader example app using asyncio and aiohttp.

advanced python

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated July 24, 2026