CONCURRENCY LAB · SCHEDULE · INSPECT · COMPARE
Work stealing: move tasks, preserve their actual work
Follow task identities and durations as idle workers steal queued work and compare the same workload without stealing.
Exact schedule state
Inspect identities, counters and transitions
A completed task must actually have run
Each seeded task has a stable identity and a duration from one to eight modeled ticks. A worker runs one active task at a time and decrements that task’s remaining work. Completion occurs only after that duration has elapsed; idle workers do not create phantom completions. Queued, active and completed identities remain separate, so the inspector can account for every task exactly once. The chart shows active tasks and queue entries with their durations rather than decorative boxes whose sizes or numbers have no effect.
Control distribution and stealing
Workers chooses one to four execution slots. Tasks creates the finite workload. Task-duration seed reproduces the same durations for a controlled comparison. Put all initial tasks on worker zero creates a deliberately skewed starting distribution; disabling it distributes tasks round-robin. Allow idle workers to steal permits an idle worker with no local queued task to take the oldest queued item from another worker. Owners pop their newest local task. The chosen victim has the largest remaining queue, with worker identifier as a tie-break. Active tasks are never stolen. These are explicit fixture policies, not a claim that every fork/join runtime makes those choices.
Compare identical work under two policies
Restore defaults: four workers, sixteen tasks, a skewed initial queue and stealing enabled. Other workers should take queued tasks from worker zero, and all sixteen eventually complete. Disable stealing without changing the seed. Only worker zero has work, so the other workers remain idle and the finish time increases for this fixture. Set one worker: enabling stealing can no longer help because there is no victim. Disable the skew and inspect a balanced initial distribution; different task lengths can still create idle workers later. Change the seed to see a different workload, but do not attribute that difference solely to the scheduling policy.
Inspect conservation and model limits
Play reveals the complete computed schedule over sixty inspection seconds. Pause holds it; Next state advances a tick; Restart rewinds; Speed changes viewing pace; Inspect time scrubs; Restore defaults resets the controls. The canvas shows at most eight queue entries per worker, while readable queues and the inspector include all identities. At completion, the sum of worker busy ticks equals the sum of task durations regardless of stealing. Finish time can differ because execution overlaps. The model has no dynamic task spawning, blocked tasks, deque contention, stealing cost, cache locality, dependencies or operating-system preemption. A steal transfers ownership once; it does not duplicate work or guarantee a speedup for every real workload.