首页  

netty中的future和promise     所属分类 netty 浏览量 1142
jdk中的Future
java.util.concurrent.Future
异步执行结果,提供方法检测执行是否完成、等待执行完成、获取结果 
get 用来获取结果,该方法会阻塞直到完成

netty中的Future
io.netty.util.concurrent.Future
addListener 添加监听器   支持回调功能
cause  操作失败,返回异常信息
boolean cancel(boolean mayInterruptIfRunning)
isSuccess  操作是否已经成功完成。
jdk中Future isDone方法,只能知道是否结束,有可能是成功完成、被取消、异常中断。
netty中Future isSuccess方法能够判断操作是否成功完成
sync方法阻塞直到操作完成 
 
ChannelFuture
operationComplete 回调方法
netty中所有的IO操作都是异步的,调用会直接返回,可通过ChannelFuture来获取操作的结果状态
ChannelFutureListener

ChannelPromise
ChannelPromise 一种可写的特殊 ChannelFuture

上一篇     下一篇
dubbo配置优先级

dubbo性能相关参数

netty实战笔记

netty耗时任务处理

netty4 ChannelInboundHandler 使用

ChannelPipeline和ChannelInitializer