by dumdumchan · 3y ago · 0 comments
val another_path = await readFile(path);
val data = await readFile(another_path);
console.log(data.length);
How would you do that using threads? val another_path = readFileSync(path);
val data = readFileSync(another_path);
console.log(data.length);
The "runtime" (for instance the OS, or a task system) will take care of scheduling other things that are ready to run while the blocking functions are "stuck". That's exactly what processes and threads had been invented for.