about Netty 4 boss Thread do?

190 views
Skip to first unread message

you fu

unread,
Nov 22, 2014, 9:10:56 PM11/22/14
to ne...@googlegroups.com
hi  all 
if the use the bloew code :
     // Configure the server.
        EventLoopGroup bossGroup = new NioEventLoopGroup(2);
        EventLoopGroup workerGroup = new NioEventLoopGroup(10);
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(bossGroup, workerGroup)
             .channel(NioServerSocketChannel.class)
             .option(ChannelOption.SO_BACKLOG, 100)
             .handler(new LoggingHandler(LogLevel.INFO))
             .childHandler(new ChannelInitializer<SocketChannel>() {
                 @Override
                 public void initChannel(SocketChannel ch) throws Exception {
                     ch.pipeline().addLast(
                             new NettyEncoder(),
                             new LineBasedFrameDecoder(8192),
                             new StringDecoder(CharsetUtil.UTF_8),
                             new FileHandler());
                 }
             });

            // Start the server.
            ChannelFuture f = b.bind(port).sync();

            // Wait until the server socket is closed.
            f.channel().closeFuture().sync();

the boss thread is 2 ,two boss threads  both contention accept cleint socket ? what's the boss thread do? 

yuanjun Li

unread,
Nov 22, 2014, 11:14:10 PM11/22/14
to ne...@googlegroups.com
according to the source code, I think only one boss thread would be started.

--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/9e68f40d-3cb7-43e6-b177-a15e3b07f421%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Norman Maurer

unread,
Nov 26, 2014, 2:06:13 AM11/26/14
to ne...@googlegroups.com
Yeah the boss group is only used for accept etc and for each ServerChannel only one Thread is used. So if you only call bind(...) one time only one of the Threads out of it will be used. 
Reply all
Reply to author
Forward
0 new messages