Netty ByteToMessageDecoder不能@sharable [英] Netty ByteToMessageDecoder can't be @sharable

查看:495
本文介绍了Netty ByteToMessageDecoder不能@sharable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MyDecoder扩展了ByteToMessageDecoder来从套接字流获取消息. 它在一个线程中工作正常.但是在更多线程中,网络专家报告说处理程序应该是可共享的" 但是,我在netty api中搜索,ByteToMessageDecoder不能为@sharable,所以我该如何使用 它在多线程中.

I use MyDecoder which extends ByteToMessageDecoder to get Message from the socket Stream. It works fine in one thread. But in more threads, the netty has reported 'the handler should be sharable' However, I search in netty api, the ByteToMessageDecoder can't be @sharable, so how can I use it in multi thread.

推荐答案

在ChannelInitializer中创建一个新实例.

Create a new instance in your ChannelInitializer.

这篇关于Netty ByteToMessageDecoder不能@sharable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆