Created
November 23, 2014 23:02
-
-
Save r01010010/c4ef8ce2f91de31d1200 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
var data = fs.readFileSync('/etc/passwd'); | |
/* This code would start 1000 simultaneous asynchronous file reads, and run the do_next_part() | |
function immediately. This has several problems: first, we’d like to wait until | |
all the file reads are done until going further.*/ | |
for(var i = 1; i <= 1000; i++) { | |
fs.readFile('./'+i+'.txt', function() { | |
// do something with the file | |
}); | |
} | |
do_next_part(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment