在netty中向self发送消息

时间:2012-10-24 06:23:51

标签: netty

我想向netty的线程调度一个作业,如果我不这样做,我必须关心线程同步,因为作业不是从客户端收到的消息触发的。 我发现ChannelPipeline有一个方法sendUpstream符合我的要求,但我无法获得所有ChannelPipeline的对象。我的意思是:

// code in thread which not belong to netty's thread
for(all pipeline)
    pipeline.sendUpstream(my_pseudo_message)

MyChannelHander.messageReceive() {
    //code to deal with my_pseudo_message
}

1 个答案:

答案 0 :(得分:0)

如果你想在Netty的Worker-Thread中执行一些东西:

channel.getPipeline().execute(new Runnable() {...});