Quantcast
Channel: Lambdas and putIfAbsent - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by Tagir Valeev for Lambdas and putIfAbsent

Note that using Java 8 ConcurrentHashMap it's completely unnecessary to have AtomicLong values. You can safely use ConcurrentHashMap.merge:ConcurrentMap<String, Long> map = new...

View Article



Answer by Stuart Marks for Lambdas and putIfAbsent

UPDATE 2015-08-01The computeIfAbsent method as described below has indeed been added to Java SE 8. The semantics appear to be very close to the pre-release version.In addition, computeIfAbsent, along...

View Article

Answer by Blank Chisui for Lambdas and putIfAbsent

AtomicLong is not really a heavy object. For heavier objects I would consider a lazy proxy and provide a lambda to that one to create the object if needed.class MyObject{ void doSomething(){}}class...

View Article

Answer by jacobm for Lambdas and putIfAbsent

Unfortunately it's not as easy as that. There are two main problems with the approach you've sketched out:1. The type of the map would need to change from Map<String, AtomicLong> to...

View Article

Lambdas and putIfAbsent

I posted an answer here where the code demonstrating use of the putIfAbsent method of ConcurrentMap read:ConcurrentMap<String, AtomicLong> map = new ConcurrentHashMap<String, AtomicLong>...

View Article

Browsing latest articles
Browse All 5 View Live




Latest Images