Big Top Task Queue
Three acts arrived at once, but the center ring can perform only one at a time. Build the scheduler that keeps every act moving in a fair order!
π§ Before we start
At the Studio Signal Switchboard, events woke up their listeners. At the Clinic Router, labels led straight to the right record. Today each event creates a labeled task. Waiting tasks join a queue, and the event loop sends them to the stage one at a time.
Arrange the event-loop recipe
Tap four visual instruction blocks in the order the circus scheduler uses them.
Schedule the arriving acts
Add the acts in arrival order, then let the event loop perform them. New arrivals wait at the back.
Predict the timer queue
Timers join the queue when their countdown finishesβnot when the timer was started. Which task reaches the stage first?
Debug the frozen circus
One giant task never gives the stage back, so every click and timer waits. Choose a repair that keeps the queue responsive.
π What you learned
- An event can create a task for a program to handle.
- A task queue keeps waiting work in arrival order: first in, first out.
- The event loop moves one waiting task onto the stage when the stage is free.
- Timers join the queue when their countdown finishes.
- Splitting long work into small turns prevents one task from blocking everything else.