下面列出了怎么用java.nio.channels.AsynchronousChannel的API类实例代码及写法,或者点击链接到github查看源代码。
public AbstractConnection(NetworkChannel channel) {
this.channel = channel;
boolean isAIO = (channel instanceof AsynchronousChannel);
if (isAIO) {
socketWR = new AIOSocketWR(this);
} else {
socketWR = new NIOSocketWR(this);
}
this.isClosed = new AtomicBoolean(false);
this.startupTime = TimeUtil.currentTimeMillis();
this.lastReadTime = startupTime;
this.lastWriteTime = startupTime;
}
public AbstractConnection(NetworkChannel channel) {
this.channel = channel;
boolean isAIO = (channel instanceof AsynchronousChannel);
if (isAIO) {
socketWR = new AIOSocketWR(this);
} else {
socketWR = new NIOSocketWR(this);
}
this.startupTime = TimeUtil.currentTimeMillis();
this.lastReadTime = startupTime;
this.lastWriteTime = startupTime;
}