ITPub博客

首页 > 应用开发 > > 为什么要放到线程中?

为什么要放到线程中?

作者:lcc 时间:2019-09-29 17:53:38 0 删除 编辑

为什么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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-09-06

  • 博文量
    119
  • 访问量
    12368