本文介绍了带有netty OIO的每通道模型单线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Netty OIO在每个通道模型上是否有单个线程意味着写或读操作一次可以在单个通道上执行?我正在编写具有少量连接(〜20)的分布式应用程序,并且我正在考虑使用Netty OIO.但是,对我来说很重要的一点是,当相应的工作线程被写入阻止时,不要在某个通道上接收消息时被阻止吗?是否可以通过Netty OIO来实现此目的,即我是否可以有一个线程在一个通道上进行写入,而有一个线程在同一通道上进行读取?

Does a single thread per channel model with Netty OIO mean that either write or read operationcan be executed on a single channel at a time?I am writing distributed applications with a small number of connections (~20) and I was thinking of using Netty OIO. However, it is very important for me not to be blocked on receiving messages on some channel while corresponding worker thread is blocked with writing?Is there a way to achieve this with Netty OIO, i.e., can I have one thread for writing on a channel and one thread for reading on the same channel?

推荐答案

在OIO中,写入将永远不会被读取阻塞.因此,您可以在等待数据接收的同时将内容写入Channel.

In OIO a write will never get blocked by a read. So you can write stuff to the Channel while it waits for data to receive.

这篇关于带有netty OIO的每通道模型单线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-13 13:52