首页 > 应用开发 > > 为什么要放到线程中?
为什么Netty服务端启动时ServerBootstrapAcceptor的添加要放到线程中?
ServerBootstrap的init()方法中,有这样一段逻辑:
1if(handler != null) { pipeline.addLast(handler);}ch.eventLoop().execute(newRunnable() { @Overridepublicvoidrun() { pipeline.addLast(newServerBootstrapAcceptor( ch, currentChildGroup, currentChildHandler, currentChildOptions, currentChildAttrs)); }});
为什么对ServerBootstrapAcceptor的添加,要放到线程中执行,而不是直接同步添加?
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2331/viewspace-3147048/ ,如需转载,请注明出处,否则将追究法律责任。