java - 如果内核不支持 AIO,java AsynchronousFileChannel 如何工作

标签 java linux aio

我有两个问题

  1. 如果我的操作系统不支持 AIO(低于 linux 2.6 等),AsynchronousFileChannel 将如何工作。

  2. 如何在AsynchronousFileChannel中追加某物,据我所知AsynchronousFileChannel只支持write(ByteBuffer, long position, A attachment, CompletionHandler handler) 和write(ByteBuffer src, long position) 都需要position参数。我应该自己算位置吗?

最佳答案

问题 2:来自 javadoc

An asynchronous file channel does not have a current position within the file. Instead, the file position is specified to each read and write method that initiates asynchronous operations.

所以是的,您需要自己跟踪位置。

关于java - 如果内核不支持 AIO,java AsynchronousFileChannel 如何工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31286258/

相关文章:

java - 为什么 `.read()` 一个数字的方法返回不同的数字

java - Spring Autowired 组件在 bean 方法中为 null

java - Gson库写入文件并只更改特定值

linux - 找不到 doc2x linux r649 zlibwapi.dll

ubuntu 16.04 不支持 java aio SO_KEEPALIVE?

java - 防止列表中的重复项目打印到单元格表gwt

linux - rsync 错误权限被拒绝

linux - 当我们向 pid 1 发送停止时,docker 如何处理子进程

c++ - 在 *nix 上了解异步编程的基础知识

linux - 在 Linux 上使用 POSIX AIO 库编译 C++ 程序