apache MINA 源码级分析-[贰]
http://rrsy23.iteye.com/blog/422689
http://rrsy23.iteye.com/blog/422589
需要先看前面的2篇 才能理解在说什么!
通过分离业务与io处理的线程池 这样 业务的阻塞不会导致IO处理的阻塞
[16:24:14] INFO [org.apache.mina.transport.socket.nio.NioSocketAcceptor] - accept an client connection thread info-->NioSocketAcceptor-1 [16:24:14] INFO [org.apache.mina.filter.logging.LoggingFilter] - OPENEDThread info--> NioProcessor-1 nextFilter is class org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1 [16:24:15] INFO [org.apache.mina.example.echoserver.EchoProtocolHandler] - OPENED Thread info--> pool-3-thread-1 [16:24:15] INFO [org.apache.mina.transport.socket.nio.NioSocketAcceptor] - accept an client connection thread info-->NioSocketAcceptor-1 [16:24:15] INFO [org.apache.mina.filter.logging.LoggingFilter] - OPENEDThread info--> NioProcessor-2 nextFilter is class org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1 [16:24:16] INFO [org.apache.mina.transport.socket.nio.NioSocketAcceptor] - accept an client connection thread info-->NioSocketAcceptor-1 [16:24:16] INFO [org.apache.mina.filter.logging.LoggingFilter] - OPENEDThread info--> NioProcessor-3 nextFilter is class org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1 [16:24:17] INFO [org.apache.mina.transport.socket.nio.NioSocketAcceptor] - accept an client connection thread info-->NioSocketAcceptor-1 [16:24:17] INFO [org.apache.mina.filter.logging.LoggingFilter] - OPENEDThread info--> NioProcessor-1 nextFilter is class org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1 [16:24:35] INFO [org.apache.mina.example.echoserver.EchoProtocolHandler] - --sleeping wake up 20 seconds---
从日志可以看出 现在 accept ioprocess iohandler各自自己的线程池 这样才 真的异步
chain.addLast("threadPool", new ExecutorFilter(Executors.newSingleThreadExecutor()));
关键所在 不加则2,3车间公用一个线程池
实践不可能单线 一般
chain.addLast("threadPool", new ExecutorFilter(Executors.newCachedThreadPool()));
用什么线程池 自己实际考虑
推荐阅读
-
STL源码分析之第二级配置器
-
Mybaits 源码解析 (九)----- 全网最详细,没有之一:一级缓存和二级缓存源码分析
-
Prioprity源码分析--priority如何实现优先级排序
-
源码级强力分析hadoop的RPC机制
-
Spring,BeanPostProcessor源码分析,彻底搞懂IOC注入及注解优先级问题!
-
lodash源码分析之baseFindIndex中的运算符优先级
-
Apache Flink源码分析---JobManager启动流程
-
Apache Commons Pool2 源码分析
-
从SpringBoot源码分析 配置文件的加载原理和优先级
-
互联网架构-Mybatis深入源码分析-014:SQLSession一级缓存原理分析