Created
November 13, 2019 15:56
-
-
Save diversemix/60cfcfb4cd378744aa03004cc4799c42 to your computer and use it in GitHub Desktop.
Test for understanding how blocking works
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
const log = console; | |
const sleep = async ms => { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
}; | |
const asyncFunc1 = async () => { | |
log.log('f1 Start'); | |
await sleep(2000); | |
log.log('f1 End'); | |
}; | |
const asyncFunc2 = async () => { | |
log.log('f2 Start'); | |
await sleep(1000); | |
log.log('f2 End'); | |
}; | |
console.log('### Startin...'); | |
asyncFunc1(); | |
console.log('### do another job....'); | |
asyncFunc2(); | |
console.log('### Stoppin...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment