Created
October 13, 2016 15:21
-
-
Save rystsov/018ff69ee32f116dc8d209cfc7de7c56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let flag = true; | |
async function frozen(promise) { | |
flag = await promise; | |
console.info("done"); | |
} | |
let complete = null; | |
frozen(new Promise((reply, reject) => { | |
complete = reply; | |
})); | |
// you'll never see 'done' | |
complete(false); | |
// even after you complete the promise | |
// because js may keep a promise on the event loop | |
// even if it was completed on the same 'thread' | |
while (flag) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment