Alternative: Event-Driven Systems
If handling some event requires waiting for I/O to complete, the thread arranges for another event to notify it of completion, and keeps right on going, e.g., asynchronous non-blocking I/O.
Structure the code as a single thread that responds to a series of events, each of which carries enough state to determine what is needed and “pick up where we left off”.
The thread continuously polls for new events, whenever it completes a previous event.
Question: in what order should events be delivered?