2

If I were to code the following code segment:

class SimpleHandler extends SimpleChannelUpstreamHandler {
    ...
    public static void main( String[] args ) throws Exception {
    ServerBootstrap b = new ServerBootstrap( 
        new NioServerSocketChannelFactory( 
            Executors.newCachedThreadPool(), 
            Executors.newCachedThreadPool(), 
            10 ));
    b.setPipelineFactory( new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception {
            return Channels.pipeline( new SimpleHandler() );
        }
    });
    b.bind( new InetSocketAddress( p ));
}

And assuming the following scenario:

  • channel C1 has input
  • netty assigns thread T1 to channel C1
  • after thread T1 has read all the input from channel C1, and while it is still processing the input, more input arrives at channel C1

My question is: will netty assign a new thread to channel C1 (assuming there are free threads in the thread pool)?

Thanks in advance

1 Answers1

0

Once a Thread / Selector is assigned to a Channel it will use the same during all of its life-time. So it will be served by the same all the time.

Norman Maurer
  • 23,104
  • 2
  • 33
  • 31
  • Thanks, Norman. So, a channel CANNOT have more than one IO thread assigned to it at any one time, right? – user1902850 Dec 16 '12 at 23:37
  • Would I be correct in saying this arises from limitations arising from select and epoll? Discussed here https://idea.popcount.org/2017-02-20-epoll-is-fundamentally-broken-12/ – robert Mar 22 '17 at 10:21