Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmaxwell/6bfcacdb15de2f535b2aaff938b107f2 to your computer and use it in GitHub Desktop.
Save johnmaxwell/6bfcacdb15de2f535b2aaff938b107f2 to your computer and use it in GitHub Desktop.
function sayHi() {
console.log("hi");
}
function blackhole() {
while (true) {
1 + 1;
}
}
setInterval((function () { sayHi() }), 1000);
setTimeout((function () { blackhole() }), 5000);
// You'll see "hi" 4-5 times and then nothing, because
// JS is single-threaded and can't execute in parallel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment