I noticed that Netty has some internal Concurrent HashMap utilities. I’m curious why Netty doesn’t use the ConcurrentHashMap that’s built into the Java Core. Is the Netty implementation better in some way, or does it have some new functionality? I’m working on a project that needs a Concurrent HashMap and I’m debating whether I should use the netty implementation, but I can’t see any difference in the source code.
I noticed that Netty has some internal Concurrent HashMap utilities. I’m curious why Netty
Share
ConcurrentHashMapdidn’t exist until JSR-166, which was released in Java 5 as thejava.util.concurrentpackage.Netty doesn’t include their own
ConcurrentHashMapbecause it’s superior – in fact, it’s certainly just a copy of JSR-166 – it’s so they can run on Java 1.4.For your own projects, you should just use
java.util.concurrent.ConcurrentHashMapif you can take a dependency on Java 5. And if you can’t, then you should just include it in your product (and change the package name so that it doesn’t conflict with the Java 5 runtime’s included projects.) Any time you can get Doug Lea or Brian Goetz to write your thread-safe code for you, you probably should.