回调接口
【Callback API】
回调 API 以异步方式执行所有操作,不会阻塞事件循环,并在完成或出错时调用回调函数。
【The callback APIs perform all operations asynchronously, without blocking the event loop, then invoke a callback function upon completion or error.】
回调 API 使用底层的 Node.js 线程池在事件循环线程之外执行文件系统操作。这些操作不是同步的,也不是线程安全的。在对同一文件进行多个并发修改时必须小心,否则可能会导致数据损坏。
【The callback APIs use the underlying Node.js threadpool to perform file system operations off the event loop thread. These operations are not synchronized or threadsafe. Care must be taken when performing multiple concurrent modifications on the same file or data corruption may occur.】