Skip to content
Sharp

Concurrency basics · interview question

Given a ConcurrentHashMap, which method would you use to atomically update a value for a given key?

Multiple choiceMediumchapter-15-curatedpremiumconcurrencyconcurrent-collections
Choose one answer
Answer and explanation

Correct answer

B. Merge(K key, V value, BiFunction remappingFunction)

Why

The merge method is used to atomically update the value associated with a key using a BiFunction, which allows you to specify how to recompute the value.

Test yourself on Concurrency basics

A free test with instant, explained results. No account needed.

Start free test
All Concurrency basics questions →