Skip to content
Sharp

Concurrency basics · interview question

Which of the following scenarios could cause a standard HashMap to enter an infinite loop?

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

Correct answer

B. Iterating while modifying in multi-threaded code.

Why

In a multi-threaded environment, if one thread resizes the HashMap while another thread is iterating over it, this can corrupt the internal structure, potentially causing an infinite loop.

Test yourself on Concurrency basics

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

Start free test
All Concurrency basics questions →