ChannelInitializer
@Sharable
默认ChannelHandler实例是不能被复用的(防止多线程安全问题),如果需要复用,则需要多实例或者@Sharable(某些ChannelHandler不可以Sharable)
1 |
|
AsciiLengthFieldBasedFrameDecoder添加@Sharable后,报错如下:
1 |
|
是因为ByteToMessageDecoder不允许@Sharable
1 |
|
This annotation is provided for documentation purpose, just like the JCIP annotations(http://www.javaconcurrencyinpractice.com/annotations/doc/).
标记为@Sharable一定要确保没有多线程安全问题