Last active
March 1, 2018 03:54
-
-
Save cloverzrg/91ee75447ab42be17c0ef7dc440a4142 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
global.a = 0 | |
let timer1 = setInterval(() => { | |
global.a++ | |
}, 1000) | |
const wait = (time) => { | |
return new Promise((res, rej) => { | |
setTimeout(res, time); | |
}) | |
} | |
const waitForAvailableProcess = async () => { | |
let loopCount = 0 | |
while (1) { | |
loopCount++ | |
if (global.a > 5) { | |
clearInterval(timer1) | |
break | |
} | |
console.log("loop:" + loopCount + ",a=" + global.a) | |
await wait(400) | |
} | |
} | |
waitForAvailableProcess() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment