What Happens When?
When we talk about running something “later,” it exposes the ugly truth that the world doesn’t stop changing just because your code is running. Computers can do more than one thing at once, and are doing that all the time. But most code isn’t written that way.
Think about some of the plugins we’ve looked at so far. What would happen if, right in the middle of running that piece of code, another player typed the same command and that same code started running from the top?
Take a look at the figure here. Each arrow and code snippet represents a set of instructions that the computer is running at the same time. We call each separate set a thread—kind of like the thread of a subplot in a novel, or the thread of one conversation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access