Netty ByteToMessageDecoder can't be @sharable

2019-05-28 12:11发布

问题:

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.

回答1:

Create a new instance in your ChannelInitializer.