2012-10-24 164 views
0

我想派遣一个工作到netty的线程,如果我不这样做,我必须关心线程同步,因为作业不是从客户端接收到的消息触发。 我发现ChannelPipeline有一个方法sendUpstream满足我的要求,但我无法获得所有ChannelPipeline的对象。我的意思是:发送消息给自己netty

// 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 
} 

回答

0

如果你想Netty中的工作线程来执行一些使用方法:

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

如果我用什么OrderedMemoryAwareThreadPoolExecutor?它仍然在I/O线程中运行?这不是我想要的... – jean

+0

channel.getPipeline()。execute(..)总是把你的工作放在I/O线程中 –

+0

如果我使用OrderedMemoryAwareThreadPoolExecutor,任何方式都可以将它分派给给定通道的ChildExecutor? – jean