当前位置: 首页 > news >正文

做网站排名公司推荐做问卷的网站哪个好

做网站排名公司推荐,做问卷的网站哪个好,php做简易网站,新浪网页版电脑版NioEventLoopGroup 可以看到NioEventLoopGroup继承了MultithreadEventExecutorGroup并且实现了EventLoopGroup接口#xff0c;而这两个类被ExecutorService修饰#xff0c;所以NioEventLoopGroup实际上是一个线程池#xff0c;池中的对象其实就是单个的NioEventLoop。 源码…NioEventLoopGroup 可以看到NioEventLoopGroup继承了MultithreadEventExecutorGroup并且实现了EventLoopGroup接口而这两个类被ExecutorService修饰所以NioEventLoopGroup实际上是一个线程池池中的对象其实就是单个的NioEventLoop。 源码解读 NioEventLoopGroup 的参数初始化 // 进入无参构造public NioEventLoopGroup() {this(0);} public NioEventLoopGroup(int nThreads) {// group所包含的executorthis(nThreads, (Executor) null);}public NioEventLoopGroup(int nThreads, Executor executor) {// 注入单例模式的提供者 this(nThreads, executor, SelectorProvider.provider());}public NioEventLoopGroup(int nThreads, Executor executor, final SelectorProvider selectorProvider) {// 注入默认的策略工厂实例this(nThreads, executor, selectorProvider, DefaultSelectStrategyFactory.INSTANCE);}public NioEventLoopGroup(int nThreads, Executor executor, final SelectorProvider selectorProvider,final SelectStrategyFactory selectStrategyFactory) { // 注入拒绝处理器super(nThreads, executor, selectorProvider, selectStrategyFactory, RejectedExecutionHandlers.reject());}protected MultithreadEventLoopGroup(int nThreads, Executor executor, Object... args) {super(nThreads 0 ? DEFAULT_EVENT_LOOP_THREADS : nThreads, executor, args);}private static final int DEFAULT_EVENT_LOOP_THREADS;static {//默认线程数是cpu核数的两倍DEFAULT_EVENT_LOOP_THREADS Math.max(1, SystemPropertyUtil.getInt(io.netty.eventLoopThreads, NettyRuntime.availableProcessors() * 2));if (logger.isDebugEnabled()) {logger.debug(-Dio.netty.eventLoopThreads: {}, DEFAULT_EVENT_LOOP_THREADS);}}构造真正的NioEventGroup protected MultithreadEventExecutorGroup(int nThreads, Executor executor,EventExecutorChooserFactory chooserFactory, Object... args) {if (nThreads 0) {throw new IllegalArgumentException(String.format(nThreads: %d (expected: 0), nThreads));}//1、//executor校验非空, 如果为空就创建ThreadPerTaskExecutor, 该类实现了 Executor接// 这个executor 是用来执行线程池中的所有的线程也就是所有的NioEventLoop其实从//NioEventLoop构造器中也可以知道NioEventLoop构造器中都传入了executor这个参数。if (executor null) {executor new ThreadPerTaskExecutor(newDefaultThreadFactory());}//2、//这里的children数组 其实就是线程池的核心实现线程池中就是通过指定的线程数组来实现 线程池//数组中每个元素其实就是一个EventLoopEventLoop是EventExecutor的子接口。children new EventExecutor[nThreads];for (int i 0; i nThreads; i ) {boolean success false;try {//3、//newChild(executor, args) 函数在NioEventLoopGroup类中实现了,// 实质就是就是存入了一个 NIOEventLoop类实例children[i] newChild(executor, args);success true;} catch (Exception e) {// TODO: Think about if this is a good exception typethrow new IllegalStateException(failed to create a child event loop, e);} finally {if (!success) {for (int j 0; j i; j ) {children[j].shutdownGracefully();}// 终止所有eventLoop上所执行的任务for (int j 0; j i; j ) {EventExecutor e children[j];try {while (!e.isTerminated()) {e.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS);}} catch (InterruptedException interrupted) {// Let the caller handle the interruption.Thread.currentThread().interrupt();break;}}}}} //4、实例化线程工厂执行器选择器: 根据children获取选择器chooser chooserFactory.newChooser(children);//5、为每个EventLoop线程添加 线程终止监听器final FutureListenerObject terminationListener new FutureListenerObject() {Overridepublic void operationComplete(FutureObject future) throws Exception {if (terminatedChildren.incrementAndGet() children.length) {terminationFuture.setSuccess(null);}}};for (EventExecutor e: children) {e.terminationFuture().addListener(terminationListener);} //6、将children 添加到对应的set集合中去重 表示只可读。SetEventExecutor childrenSet new LinkedHashSetEventExecutor(children.length);Collections.addAll(childrenSet, children);readonlyChildren Collections.unmodifiableSet(childrenSet);}children[i] newChild(executor, args); /*** newChild(executor, args) 里的方法* 我们可以看到 返回的就是一个 NioEventLoop*/ Override protected EventLoop newChild(Executor executor, Object... args) throws Exception {return new NioEventLoop(this, executor, (SelectorProvider) args[0],((SelectStrategyFactory) args[1]).newSelectStrategy(), (RejectedExecutionHandler) args[2]); }1. NioEventLoopGroup初始化时未指定线程数那么会使用默认线程数即 线程数 CPU核心数 * 2 2. 每个NioEventLoopGroup对象内部都有一组可执行的NioEventLoop数组其大小是 nThreads, 这样就构成了一个线程池 一个NIOEventLoop可以理解成就是一个线程。 3. 所有的NIOEventLoop线程是使用相同的 executor、SelectorProvider、SelectStrategyFactory、RejectedExecutionHandler以及是属于某一个NIOEventLoopGroup的。这一点从 newChild(executor, args); 方法就可以看出newChild()的实现是在NIOEventLoopGroup中实现的。 4. 当有IO事件来时需要从线程池中选择一个线程出来执行这时候的NioEventLoop选择策略是由GenericEventExecutorChooser实现的并调用该类的next()方法。 5. 每个NioEventLoopGroup对象都有一个NioEventLoop选择器与之对应其会根据NioEventLoop的个数动态选择chooser如果是2的幂次方则按位运算否则使用普通的轮询
http://wiki.neutronadmin.com/news/304961/

相关文章:

  • 开源 企业网站一元域名注册永久
  • 吴江区建设局网站网站如何做中英文效果
  • 外贸婚纱网站 侵权郑州市建设厅网站
  • 网站设计的书网站建设公司源码
  • 北京大兴网站建设公司咨询php怎样做网站管理后台
  • 制作网站的图片素材做防腐木网站
  • 网站关键词代码怎么做wordpress 代码位置
  • 网站建设需要用软件asp程序设计做网站
  • 域名备案和网站备案西乡做网站的公司
  • 常州建设银行网站首页大型购物网站建站
  • 邢台微信网站网站设计一般什么字体
  • 湖南官网网站推广软件智慧门店管理服务平台
  • 做设计排版除了昵图网还有什么网站怎么做一个网站出来
  • 网站建设工作进度wordpress 浮动留言框
  • 网站由哪几个部分组成信阳专业做网站公司
  • 郑州微科网站建设微山网站建设多少钱
  • 深圳建立网站的公司做网站比较专业的公司
  • 网站建设与设计开题报告抖音小程序在哪里
  • 常州网站建设运营网页设计与制作教程书电子版
  • 国外设计网站app有哪些移动网站开发语言
  • 杭州建设实名制报备网站盐城z做网站
  • 江苏 网站集约化建设方案网页游戏网站源码
  • 网站优化外包多少钱厦门双模网站
  • 萍乡招聘网站建设西安网站搭建公司
  • 岳阳做网站公司wordpress没权重
  • pc网站 手机网站 微信网站 上海水果营销软文
  • 网站制作公司 深圳网络营销推广8种方法
  • 广州白云学校网站建设做全屏网站设计时容易犯的错
  • 网站宽度960全球设计网优秀版式作品
  • 东莞著名网站建设企业做外贸怎么看外国网站