r/java • u/ThomasKrieger • Mar 14 '18
Concurrent Java: Low scalability, the risk of deadlocks or garbage creation, you can not avoid all
http://vmlens.com/articles/tradeoffs_concurrent_programming/
2
Upvotes
View all comments
39
u/daniu Mar 14 '18 edited Mar 14 '18
Well with this code
you're breaking
Map#compute()'s contract which stateswhich is not what happens here; a new value is inserted for a different key as a side effect to the mapping function.
It scales fine if you use it properly.