3 ms·
java.util.HashMap is not thread-safe, so using it in the context of multiple threads reading from it is less than ideal. The great thing about Scala's immutabl
by bad_user 13y ago
java.util.HashMap is not thread-safe, so using it in the context of multiple threads reading from it is less than ideal.
The great thing about Scala's immutable HashMap is that in terms of concurrency it is worry-free. You couple it with an AtomicReference and presto, you've got a non-blocking, concurrent HashMap.
I work on a really high-volume web service that's built on top of Scala. The performance of Scala's immutable collections has been the least of my worries.
- trailfox 13y agoScala's immutable hashmap is about 4-5x slower than ju.HashMap for reads and 6-7x slower for inserts.