1

is it ok to understand that when "fs.readFile(~) is called in the code below, a thread to read the disk is automatically generated in readFile's inner procedure? And when the assigned job is done, the thread runs the callback function?

  • sorry that i'm not good at English and a student studying OS recently.
var fs = require('fs');
console.log(2); 
fs.readFile('data.txt', {encoding: 'utf8'}, function(err, data){
  console.log(3); 
  console.log(data); 
})
console.log(4);
user7024
  • 311
  • 2
  • 10
  • See also [How to create threads in nodejs](https://stackoverflow.com/questions/18613023/how-to-create-threads-in-nodejs) – xmojmr May 31 '19 at 05:08

0 Answers0