Created
August 5, 2016 01:51
-
-
Save RavenZZ/d51b4762ef1f56613309f2a1b41ce414 to your computer and use it in GitHub Desktop.
javascript模拟线程阻塞
This file contains hidden or 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
| function sleep(milliSeconds) { | |
| var startTime = new Date().getTime(); | |
| while (new Date().getTime() < startTime + milliSeconds); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
点赞,Promise的方案阻塞不了主线程