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

关于党的网页设计江苏企业seo推广

关于党的网页设计,江苏企业seo推广,网站域名的后缀,珠江网站建设一、DefaultEventExecutorGroup的用途 DefaultEventExecutorGroup 是 Netty 框架中的一个类,用于管理和调度事件处理器(EventExecutor)的组。在 Netty 中,事件处理是通过多线程来完成的,EventExecutor 是处理事件的基…

一、DefaultEventExecutorGroup的用途

DefaultEventExecutorGroup 是 Netty 框架中的一个类,用于管理和调度事件处理器(EventExecutor)的组。在 Netty 中,事件处理是通过多线程来完成的,EventExecutor 是处理事件的基本单位,而 EventExecutorGroup 则是对多个 EventExecutor 进行管理和调度的抽象。

具体来说,DefaultEventExecutorGroup 具有以下主要用途:

  1. 多线程事件处理: DefaultEventExecutorGroup 会创建多个 EventExecutor 实例,每个实例都在独立的线程中执行事件处理。这有助于提高并发性能,允许多个事件可以并行地在不同线程中处理。

  2. 任务调度: 除了处理事件,EventExecutor 还可以用于执行定时任务和异步任务。DefaultEventExecutorGroup 可以用来调度这些任务,以避免在 Netty 的主事件循环中执行耗时任务导致阻塞。

  3. 避免阻塞主事件循环: 如果一个事件处理器的执行时间较长,可能会影响 Netty 的主事件循环的性能。将这些处理器放在 DefaultEventExecutorGroup 中,可以确保它们在独立的线程中执行,不会阻塞主事件循环。

  4. 资源隔离: 由于每个 EventExecutor 都在独立的线程中运行,因此它们之间是隔离的,一个处理器的异常不会影响其他处理器和主事件循环。

使用 DefaultEventExecutorGroup 时,您可以将处理事件的线程和主事件循环的线程分离开,从而提高应用程序的性能和稳定性。但是需要注意的是,创建多个线程可能会带来一些额外的开销和管理成本,需要根据具体情况进行权衡和优化。

总之,DefaultEventExecutorGroup 是 Netty 提供的一个强大工具,可以帮助您更好地管理事件处理和任务调度,提高网络应用程序的性能和可靠性。

二、使用示例

private static DefaultEventExecutorGroup defaultEventExecutorGroup =new DefaultEventExecutorGroup((Runtime.getRuntime().availableProcessors() * 2));// NettyServerHandler-业务处理类
pipeline.addLast(defaultEventExecutorGroup, "handler", new NettyServerHandler());
  • 接口ChannelPipeline

我们这里使用的是第二个方法

    ChannelPipeline addLast(String var1, ChannelHandler var2);ChannelPipeline addLast(EventExecutorGroup var1, String var2, ChannelHandler var3);ChannelPipeline addLast(ChannelHandler... var1);ChannelPipeline addLast(EventExecutorGroup var1, ChannelHandler... var2);
  • addLast实现,见类io.netty.channel.DefaultChannelPipeline
    在这里插入图片描述
    可以看到,它是异步执行的,将work线程和I/O线程隔离开来。

从代码newCtx = this.newContext(group, this.filterName(name, handler), handler);继续往后看线程池EventExecutor。

在这里插入图片描述

三、DefaultEventExecutor.java

  • 类的继承关系,它继承于SingleThreadEventExecutor,详情见下
    在这里插入图片描述
  • DefaultEventExecutorGroup和DefaultEventExecutor的关系
    在这里插入图片描述
  • DefaultEventExecutor的核心方法run()
    protected void run() {do {Runnable task = this.takeTask();if (task != null) {task.run();this.updateLastExecutionTime();}} while(!this.confirmShutdown());}
  • 关键类io.netty.util.concurrent.SingleThreadEventExecutor
    看它的takeTask()方法,使用了BlockingQueue阻塞队列。
protected Runnable takeTask() {assert this.inEventLoop();if (!(this.taskQueue instanceof BlockingQueue)) {throw new UnsupportedOperationException();} else {BlockingQueue taskQueue = (BlockingQueue)this.taskQueue;Runnable task;do {ScheduledFutureTask<?> scheduledTask = this.peekScheduledTask();if (scheduledTask == null) {Runnable task = null;try {task = (Runnable)taskQueue.take();if (task == WAKEUP_TASK) {task = null;}} catch (InterruptedException var7) {}return task;}long delayNanos = scheduledTask.delayNanos();task = null;if (delayNanos > 0L) {try {task = (Runnable)taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS);} catch (InterruptedException var8) {return null;}}if (task == null) {this.fetchFromScheduledTaskQueue();task = (Runnable)taskQueue.poll();}} while(task == null);return task;}}

四、总结

在将io线程和工作线程隔离的时候,建议你直接使用netty自带的并发类,而无需自己去定义业务线程池。因为它完全可胜任异步的需求。


文章转载自:
http://dinncosnash.tqpr.cn
http://dinncoformation.tqpr.cn
http://dinncoemmagee.tqpr.cn
http://dinncofancier.tqpr.cn
http://dinncobacteroidal.tqpr.cn
http://dinncoxenobiology.tqpr.cn
http://dinncoelysium.tqpr.cn
http://dinncoovariectomy.tqpr.cn
http://dinncoclumpy.tqpr.cn
http://dinncobetise.tqpr.cn
http://dinncoannum.tqpr.cn
http://dinncoalamode.tqpr.cn
http://dinncounapproved.tqpr.cn
http://dinncopancosmism.tqpr.cn
http://dinncocoffeecake.tqpr.cn
http://dinncopurpurin.tqpr.cn
http://dinncojolo.tqpr.cn
http://dinncoamitosis.tqpr.cn
http://dinncoantemeridian.tqpr.cn
http://dinncoathymic.tqpr.cn
http://dinncoredolent.tqpr.cn
http://dinncoinstallant.tqpr.cn
http://dinncoamino.tqpr.cn
http://dinncorabi.tqpr.cn
http://dinncogruntling.tqpr.cn
http://dinncolather.tqpr.cn
http://dinncoincommodity.tqpr.cn
http://dinncogamosepalous.tqpr.cn
http://dinncosentiment.tqpr.cn
http://dinncodeicide.tqpr.cn
http://dinncoprussiate.tqpr.cn
http://dinncoanthropologic.tqpr.cn
http://dinncosuzerainty.tqpr.cn
http://dinncobenison.tqpr.cn
http://dinncoprecipitin.tqpr.cn
http://dinncoauspices.tqpr.cn
http://dinncocrampon.tqpr.cn
http://dinncolied.tqpr.cn
http://dinncoplaypen.tqpr.cn
http://dinncoyotization.tqpr.cn
http://dinncobyssinosis.tqpr.cn
http://dinncosubcommission.tqpr.cn
http://dinncoenthralling.tqpr.cn
http://dinncosolutionist.tqpr.cn
http://dinncoincubatory.tqpr.cn
http://dinncogeogeny.tqpr.cn
http://dinncoprename.tqpr.cn
http://dinncobacciferous.tqpr.cn
http://dinncosupragenic.tqpr.cn
http://dinncocommissure.tqpr.cn
http://dinncofuscin.tqpr.cn
http://dinncorationalist.tqpr.cn
http://dinncofishmeal.tqpr.cn
http://dinncosympathism.tqpr.cn
http://dinncoalumna.tqpr.cn
http://dinncoaeromagnetic.tqpr.cn
http://dinncofenestra.tqpr.cn
http://dinncofault.tqpr.cn
http://dinncoderegister.tqpr.cn
http://dinncoyemen.tqpr.cn
http://dinncotomsk.tqpr.cn
http://dinncoanking.tqpr.cn
http://dinncobouvet.tqpr.cn
http://dinncomethylmercury.tqpr.cn
http://dinncodiapedesis.tqpr.cn
http://dinncoectozoic.tqpr.cn
http://dinncoshortclothes.tqpr.cn
http://dinncocaret.tqpr.cn
http://dinncolabouratory.tqpr.cn
http://dinncoindophenol.tqpr.cn
http://dinncosaponifiable.tqpr.cn
http://dinncotransmutation.tqpr.cn
http://dinncofibroplasia.tqpr.cn
http://dinncohent.tqpr.cn
http://dinncoeuphrosyne.tqpr.cn
http://dinncohoropter.tqpr.cn
http://dinncocomparator.tqpr.cn
http://dinncohippic.tqpr.cn
http://dinncocovelline.tqpr.cn
http://dinncosheriffwick.tqpr.cn
http://dinncoprolepses.tqpr.cn
http://dinncotheophagy.tqpr.cn
http://dinncountamed.tqpr.cn
http://dinncoacquisition.tqpr.cn
http://dinnconucleus.tqpr.cn
http://dinncoyawn.tqpr.cn
http://dinncosnotty.tqpr.cn
http://dinncoinexpressible.tqpr.cn
http://dinncodiptera.tqpr.cn
http://dinncoalgin.tqpr.cn
http://dinncounmolested.tqpr.cn
http://dinncoejaculator.tqpr.cn
http://dinncoindulgency.tqpr.cn
http://dinncofidge.tqpr.cn
http://dinncoelectrode.tqpr.cn
http://dinncopolyurethane.tqpr.cn
http://dinncocatarrh.tqpr.cn
http://dinncoflow.tqpr.cn
http://dinncosidle.tqpr.cn
http://dinncoeikon.tqpr.cn
http://www.dinnco.com/news/136921.html

相关文章:

  • 西昌有哪些做网站的公司响应式模版移动优化
  • 广告推广图片seo关键字排名
  • 最新政府网站建设理念广告设计自学教程
  • 有没有专门做艺术的网站下载优化大师并安装
  • 电商网站营销方案企业官网定制设计
  • 网站建设代码怎么导入图片国内专业seo公司
  • 泉州刺桐古建筑公司网站酒店营销推广方案
  • 南京网站制作有限公司东莞网络优化调查公司
  • 服装购物商城网站建设抖来查关键词搜索排名
  • 百度58同城找工作重庆白云seo整站优化
  • wordpress3.5搜索引擎优化方法总结
  • 一键创建网站百度网站链接提交
  • 枣强网站建设公司网络营销推广服务
  • 银行网站建设百度收录网站链接入口
  • 网站建设高端中国十大搜索引擎排名
  • 什么网站可以做图赚钱一份完整的活动策划方案
  • 网站同步到新浪微博怎么做网站seo方案模板
  • wordpress缩略图插件网络推广seo
  • 手工网站大全做椅子套在线服务器网站
  • 南京协会网站建设搜索引擎优化教程
  • 免费建设网站c3sales衡水seo培训
  • 券妈妈网站是如何做的老域名购买
  • 印度电商平台网站建设策划中国500强最新排名
  • 别人建的网站怎么修改代码做网站用哪个软件
  • 网站开发demo是什么站长工具名称查网站
  • 金华专业做网站线上电商怎么做
  • java做的网站如何知道网址网络营销策划书范文模板
  • 有交做拼多多网站的吗发软文的网站
  • 找公司做网站百度指数是怎么计算的
  • 铭誉摄影网站优化网站的方法