What is really going on behind the scenes with asynchronous functions?
Does it open a new thread and allow the OS to start and run it?
If so, could this cause deadlocks or other thread problems?
Here is an example of an asynchronous method:
var fs = require('fs')
var file = process.argv[2]
fs.readFile(file, function (err, contents) {
var lines = contents.toString().split('\n').length - 1
console.log(lines)
})
source
share