I am working on creating a Snappy Encoder and Decoder for Netty. I am looking at ZlibEncoder to see how it is implemented, but noticed that ChannelHandlerContext is volatile, finished is an AtomicBoolean, and z (ZStream) has a sync block. My question is why? Since a new ZlibEncoder is created for each channel, why are these needed?
thanks
dave
Its needed because downstream events can be triggeres by any thread (for example writes). Upstream events are only executed by one thread and so its not needed there (a Decoder only handles upstream events)